I want to create a custom checkbox control that simply sets a flag in jquery / javascript: if flag = 'clustered' is checked or if unchecked flag = 'unclustered'. So far I have a control on the map, but this is not a checkbox and how can I get the status of the checkbox - if it is checked or not checked.
the code:
function MapShowCommand() { alert("checked / unchecked"); //set flag } L.Control.Command = L.Control.extend({ options: { position: 'topleft', }, onAdd: function (map) { var controlDiv = L.DomUtil.create('div', 'leaflet-control-command'); L.DomEvent .addListener(controlDiv, 'click', L.DomEvent.stopPropagation) .addListener(controlDiv, 'click', L.DomEvent.preventDefault) .addListener(controlDiv, 'click', function () { MapShowCommand(); }); var controlUI = L.DomUtil.create('div', 'leaflet-control-command-interior', controlDiv); controlUI.title = 'Map Commands'; return controlDiv; } }); var test = new L.Control.Command(); map.addControl(test);
javascript jquery map leaflet
user2906420
source share