Open wambacher opened 3 years ago
What is selected in the tree is consistent with the map. If you add a baselayer (that is in the tree) to the map, it will appear marked in the tree. The same for the overlays.
If you care about how the tree is expanded when you create it, there is a method that may help you:expandSelected
Hi,
my old application used to save the layer tree state (which layers are selected, which submenues have been opened or closed, which children are open, the complete tree layout) using cookies or localStorage. This happens when the user is closing the page (something like "$(window).on("unload", function(e){ .. save tree state });") and the next time the tree will be opened like before.
You may check the old project https://wambachers-osm.website/Emergency.html to see, what i'm talking about. (Only data for Germany, Austria and Switzerland)
Tracking, which base layer or overlay layer is changing, is quite simple using map.on(baselayerchange) or map.on (overlayadd, overlayremove), but i need the full state of the tree.
Is there any way to do this using Leaflet.Control.Layers.Tree?
Regards walter