Is there any possibilities to realize multi-filter on WebGlPointsLayer

China☆狼群 提交于 2021-02-10 12:16:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!