Multiple filters with WebGL PointsLayer on Openlayers

285 Views Asked by At

I can't find a way to filter the same variable several times dynamically. For a variable given, let's say testVar, I know I can do it this way :

const [testStyle] = useState({
    variables: {
      testVar: 'MY_VALUE_SEARCHED',
      testVar2: 'MY_SECOND_VALUE_SEARCHED',
    },
    filter: ['==', ['get', 'featureTest'], ['var', 'test']] && ['==', ['get', 'featureTest'], ['var', 'test2']] ,

But what I want is having a search box allowing multiple values, pushing it into testStyle.variables.testVar into an array, like this: testVar: ['MY_VALUE_SEARCHED','MY_SECOND_VALUE_SEARCHED'] but I can't find a way to write my filter function with an array

1

There are 1 best solutions below

0
On

You should use 'all' expression to achieve that. Put all the filters as parameters to 'all'. Described here. Your code should be something like;

filter: ['all', 
         ['==', ['get', 'featureTest'], ['var', 'test']], 
         ['==', ['get', 'featureTest'], ['var', 'test2']],
        ]