问题
I'm using React, OpenLayers & https://tileserver.readthedocs.io/en/latest/index.html to take src for my WebGlPointLayer. I've got a lot of data to display on the highest zoom. Now I'm going to create some filters, so following OpenLayers example (https://openlayers.org/en/latest/examples/filter-points-webgl.html) I've done the same for my porject. The problem is the multiple filters realization. Filter is done by style.variables and style.filter.
{
variables: defaultVariables,
filter: ['between', ['get', 'i'], ['var', 'volumeMnemonicsFrom'], ['var', 'volumeMnemonicsTo']],
symbol: {
symbolType: 'circle',
size: [10, 10],
color,
rotateWithView: false,
offset: [0, 0],
},
}
Is there any possibilities to realize multiple filters by WebGLPointsLayer style property?
回答1:
what you need to do is simply using 'all' expression and putting all filter definitions as parameter of it. Something like this:
filter: ['all',
['between', ['get', 'i'], ['var', 'volumeMnemonicsFrom'], ['var', 'volumeMnemonicsTo']],
['between', ['get', 'anotherFilterField'], ['var', 'minAnotherFilterField'], ['var', 'maxAnotherFilterField']],
],
you can check the source code of expressions here. It's a pity the all
value is missing in the original example of the WebGlPointsLayer in the openlayers page.
来源:https://stackoverflow.com/questions/59153380/is-there-any-possibilities-to-realize-multi-filter-on-webglpointslayer