jjimenezshaw / Leaflet.Control.Layers.Tree

a Tree Layers Control for Leaflet
https://jjimenezshaw.github.io/Leaflet.Control.Layers.Tree/examples/basic.html
BSD 3-Clause "New" or "Revised" License
146 stars 36 forks source link

Update dinamically the menu #68

Open leonardogonfiantini opened 1 year ago

leonardogonfiantini commented 1 year ago

Hi, I am currently working on a GIS web app that uses this plugin to create a dynamic menu of WMS layers. I have encountered a problem regarding updating this menu dynamically from different components (I'm using Svelte). To resolve this issue, I have created baseOverlays in the window, and then I update the window.baseOverlays object for any wms that the user adds dinamically from a different component, so i walk inside the object to find the correct subsesction of the wms then i add it to the children array of the subsection, then I call the setOverlayTree(window.baseOverlays) function to refresh the menu with the new layer. It works fine, but I am wondering if it's possible to create a function that can dynamically update the menu, i can work on that.

albfan commented 9 months ago

I'm checking if that can be done through eventedClasses and some improvements.