Hi,
I’m using Lizmap Web Client 3.7 and I would like to automatically show or hide the legend of each individual layer in the layer panel when the user checks or unchecks that layer.
In older versions of Lizmap (before 3.7), I used JavaScript to simulate a click on the expandable legend toggle, but in 3.7 the structure seems to have changed.
Now, each layer appears like this in the HTML:
<div class="layer"> <input type="checkbox" /> <img class="legend" src="..." /> <label>Layer name</label> </div>
There is no .expandable
element anymore. The legend image is already present in the DOM as an <img class="legend">
.
What I want is simple:
- When the layer is checked, the legend (
img.legend
) should be visible. - When the layer is unchecked, the legend should be hidden.
Is there a recommended way to do this in Lizmap 3.7?
Thanks!