-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Legend is empty but visible when no linked layers are visible #946
Comments
I've added the feature to hide the legend when empty : see https://viglino.github.io/ol-ext/examples/legend/map.control.legend.layer.html |
That looks beautiful! |
I have just tried the 4.0.9 version and it is not hiding the label for me. Now, the way I am adding or removing layers is by enabling/disabling them:
Should this be triggering the new mechanism to detect empty legends? Or would I need to remove the layer from the map? |
The map legend collapse when there is no item in it. |
You are right. Just doing setVisible disables the legend: https://jsfiddle.net/t95u7bcp/ Let me review my code. For some reason the ol-empty class is not being added to the legend's button's parent. Maybe I did something wrong in the upgrade steps. |
Legends can be associated to layers, as we can see in the corresponding sample: https://viglino.github.io/ol-ext/examples/legend/map.control.legend.layer.html
If none of the layers are visible, the legend balloon and the close icon are still visible. In the above example, just unselect both layers, and the balloon stays with just "Legend" and the close icon.
Ideally, I would expect that the whole legend would be invisible if none of the associated layers are visible (and maybe the contracted legend button could be grayed out).
The text was updated successfully, but these errors were encountered: