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

check_uncheck #13

Closed astridx closed 4 years ago

astridx commented 4 years ago

Idea for https://github.com/jjimenezshaw/Leaflet.Control.Layers.Tree/issues/12

I thought about how a check and uncheck would be possible. Here's what I use so far.

astridx commented 4 years ago

Of course, your version is much better than mine. I created my version for a map that has 18 overlays and no subtree. That was the most efficient solution. Thank you for your improvements which was without error for me.

It is only a pity that JavaScript functions are assigned in the Layer-Tree object. I have an example where I have the tree as a JSON in a separten file and read it in using JSON.parse. This allows users to change the Layertree themselves without JavaScript. I can not easily do that with the new features.

jjimenezshaw commented 4 years ago

In the new feature you can use a callback or directly a value (true or false) in the selectAll field. The callback lets you do things dynamically/fancy. If you do not need it, just use the booleans. I will document that when I have a bit of time.