问题描述
我正在使用 React、OpenLayers 和https://tileserver.readthedocs.io/en/latest/index.html 为我的 WebGlPointLayer 获取 src.我有很多数据要在最高变焦上显示.现在我要创建一些过滤器,所以按照 OpenLayers 示例(https://openlayers.org/en/latest/examples/filter-points-webgl.html) 我为我的项目做了同样的事情.问题是多个过滤器的实现.过滤器由 style.variables 和 style.filter 完成.
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],
},
}
是否有可能通过 WebGLPointsLayer 样式属性实现多个过滤器?
Is there any possibilities to realize multiple filters by WebGLPointsLayer style property?
推荐答案
您需要做的只是使用 'all' 表达式并将所有过滤器定义作为它的参数.像这样:
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']],
],
你可以查看表达式的源码 在这里.遗憾的是,在 openlayers .
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.
这篇关于是否有可能在 WebGlPointsLayer 上实现多过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!