0

Where exactly are the leaflet controls stored that are added to the map? So at anytime in the app, I can check something like

if(controls.polyline.enabled==true)

My guess is its somewhere in the map.layers. But theres a lot of layers there. Any way to identify which one is our control layer? and then the attribute which checks if it is currently enabled or disabled.

0

Leaflet has no central repository/catalog of controls, neither has each control some default enabled/disabled property.

The closest you can get in Leaflet.draw plugin to check presence of individual draw elements in draw toolbar is to iterate through internal drawControl._toolbars.draw._modes object. This will list all active draw elements.

If drawControl is draw control created with new L.Control.Draw(..., then active draw elements can be listed with:

for (var drawMode in drawControl._toolbars.draw._modes) {
  if (drawControl._toolbars.draw._modes.hasOwnProperty(drawMode)) {
     console.log(drawMode);
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.