Skip to content Skip to sidebar Skip to footer

Openlayers 4 - Make Layer Invisible On Feature Click

I have a map with 2 layer's containing features (markers). I have made it so that if the map is zoomed in far enough, 1 layer will become invisible and the other will become visibl

Solution 1:

The ol.interaction.Select selected features are added to an internal unmanaged layer.

This is why the selected feature is visible even if the underlying layer is not.

You could unselect the selected features while you zoom on it using select_interaction.getFeatures().clear() (just like clicking away).

I also suggest you to use layer's min/maxResolutions (see http://openlayers.org/en/latest/apidoc/ol.layer.Base.html ) to toggle layers visibility.

Post a Comment for "Openlayers 4 - Make Layer Invisible On Feature Click"