I'd like to identify the layers that are currently active (which basemap is currently in view and which overlays are currently turned on).
Was hoping to find something akin to getActiveLayers
in the Leaflet API (http://leafletjs.com/reference.html/) but I'm not seeing anything…
Best Answer
Well, one option I've come across (to answer my own question) is a plugin created by vogdb.
This plugin contains methods
getActiveBaseLayer()
andgetActiveOverlayLayers()
.The following, from vogdb's github page, demonstrates how vogdb's
activeLayers
control can be used in place of the standard leafletlayers
control making the 2 methods available.The plugin can be found on github: https://github.com/vogdb/Leaflet.ActiveLayers
And for referencing purposes, I found the link to vogdb's plugin here: http://leaflet.uservoice.com/forums/150880-ideas-and-suggestions-for-leaflet/suggestions/3777550-get-active-baselayer