Skip to content
Advertisement

Filter features with properties in OpenLayers

I’d like to filter features on the map using the feature properties.

For example if I have this property in the geojson:

JavaScript

And I want to see only featuers with Start > 10, how can I implement that features with Start < 10 are hidden?

If I change the style with following code the features are transparent but they are still available after click if I use forEachFeatureAtPixel. I want that features are not displayed and there are not available for clicking etc.

JavaScript

I tried also to use the visible like this but it doesn’t work:

JavaScript

Advertisement

Answer

Transparent fill cannot be seen but is hit detected (so you can select a polygon by clicking inside it). To avoid display and hit detection simply don’t return a style

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement