日安,
我有一个geojson(类似于下面),我正面临着一个表达式的麻烦,这个表达式在没有晋升的情况下使用时效果很好。
JSFiddle:
https://jsfiddle.net/dollysingh3192/w6bzsx84/7/GeoJson
{
'type': 'FeatureCollection',
'features': [
{
"geometry": {
"type": "Point",
"coordinates": [
8.612079620361328,
-2.932969060251523
]
},
"type": "Feature",
"properties": {
"id": "GMYTEORRGI5DQ",
"sid": "s_133",
"n": "15",
"r": "13",
"s": "312",
"sz": 5.5,
"m": "n",
"ri": 13,
"si": 7
},
"id": 11578
}
]
}工作
下面的表达式工作得很好,并从Map中提取了一个特性(不使用promoteId)
mapInstance.queryRenderedFeatures({ layers: ['seat'], filter: ["any", ["==", ["id"], 21762]] });工作全球综合框架:

不工作
但是在geojson源代码中使用promoteId时,表达式根本不起作用。
mapInstance.queryRenderedFeatures({ layers: ['seat'], filter: ["any", ["==", ["id"], "GMYTEORRGI5DQ"]] });不工作的全球综合框架:

但是,我注意到setFilter和setFeatureState可以很好地处理相同的表达式。
mapInstance.setFilter('seat', ["match", ["id"], "GMYTEORRGI5DQ", true, false]); //Works fine使用setFilter的GIF:(不知道它为什么工作)。链接
请指点。我在这里做错什么了吗?
发布于 2021-01-05 21:37:13
若要获取属性数据,请使用get
这样试一试
mapInstance.queryRenderedFeatures({
layers: ['seat'],
filter: ["==", ["get", "id"] ,"GMYTEORRGI5DQ"]
});更新:
在id/promoteId上发送到fitler
mapInstance.queryRenderedFeatures({
layers: ['seat'],
filter: ['==', 'id', 'GMYTEORRGI5DQ']
})https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/#id
https://stackoverflow.com/questions/65583108
复制相似问题