How to create filter on layer with dynamic properties

50 views Asked by At

From a source in geojson (points features only), I want to create a filter with dynamic properties, with AND and OR conditions.

My code :

let filter = ['any'];
currentLayerFilters.forEach(function (layers) {
    filter.push(['==', layer, ['get', 'layerType']]);
});

And in map.addLayer() :

filter: [
    'all',
    ['has', 'point_count'],
    filter
],

The filter ['has', 'point_count'] is mandatory so need to be true. Filters in "any" have to be least 1 at true to show the point.

On the map, i don't have any error, and no point is on the map. What filter i need to create ? I try with filter '==' and 'in', but no difference.

I 'console.log' variable filter and it contains valid filters with the layerType in the geojson.

0

There are 0 answers