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


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.

| improve this question | | | | |

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)) {
| improve this answer | | | | |

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.