Closed astridx closed 2 years ago
This plugin is designed to work with Layers, enabling or disabling them. You want to go further, and add some logic depending on how the different layers are selected. Such a functionality is not there.
However, you can try to implement the logic in your code, using the tree just as the UI tree. Try adding "virtual layers" (maybe an empty layerGroup?). Then, when a "virtual layer" is added or removed (there are Leaflet events for that), you add or remove your data. For that you have to keep the state, or ask the map if a layer is in the map or not every time.
You can have a look at the advanced functionality eventedClasses
(not very tested), but I think it is not what you need.
If you get a nice solution, you can share it with us :)
Thank you very much for your feedback @jjimenezshaw
You are right. This plugin is for displaying the layers and not for creating them. But it could have been that someone here already had the same problem and solved it. I'm planning a solution right now. When I have one that is generally usable, I'll be happy to share it here.
I use Leaflet.Control.Layers.Tree to display properties that I import via a GeoJSON file. That you very much for this.
I create an overlay that contains for example all houses that are for sale. Another overlay shows all objects that are suitable for living in. So far so good.
Now I would like to display the intersection. So I want that if both checkboxes (sellable and livable) are checked, only houses that are sellable and livable are shown. Properties that are sellable but not livable should not shown.
At first glance, it looks to me like it is mandatory that I create a separate layer for this and add it to the tree. But I have the feeling, that others have this issue too and there must be a better solution for this!
It would be kind, if someone can point me to a better solution.