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

Link Tag ID to Checkbox programmatically #8

Closed mho22 closed 5 years ago

mho22 commented 5 years ago

In my project's scope, I had to set an event listener to the checkbox to link the action of 'checking' it to another Component. The only way I found was to link its tag ID during the process of creation. Hope it should help.

It gives the opportunity to assign an additional event to this 'checked' event because of the retrieving of its own Tag ID

[ Possibility to link this to the _createRadioElement method too ]

jjimenezshaw commented 5 years ago

I see your purpose. However this solution is focused only in the checkboxes.

I recommend that you use instead the event overlayadd on the map. To detect that it is the layer you need, you can use L.Util.stamp(layer) to compare properly. map.on('overlayadd', function(ev) { console.log(ev); });

mho22 commented 5 years ago

Thanks a lot for your enlightenments, I tried your solution and it worked like a charm.

Closed !