我正在做一个使用mapbox的室内项目,我正在寻找一种方法来显示/隐藏具有特定属性level=x的特征(楼层)。在mapboxjs的第一个版本中,可以使用this。现在在GL版本中,我可以很容易地show/hide a layer using a filter,但这不是我的目标,因为层已经定义了(房间,走廊,楼梯...)并且不依赖于楼层:
{
"id": "rooms",
"filter": [
"all", [
"==",
"type",
"room"
], [
"!in",
"subtype",
"stairs",
"elevator"
]
],
"source": "indoorSource",
"source-layer": "indoor",
...
},
{
"id": "handrails",
"filter": [
"==",
"handrail",
"yes"
],
"source": "indoorSource",
"source-layer": "indoor",
...
}我可以查询我想要使用哪些功能:
map.querySourceFeatures("indoorSource", {sourceLayer: "indoor", filter: ["==", "level", "2"]})但是我没有找到一种方法来显示/隐藏返回的特性。
有关信息: indoorSource是来自For服务器的矢量磁贴:
"indoorSource": {
"type": "vector",
"tiles": ["http://xxx.xxx/tiles/{z}/{x}/{y}.pbf"]
}提前谢谢你,
蒂波特
发布于 2016-04-13 06:09:11
就像Map#querySourceFeatures一样,Map#setFilter使用过滤器来显示/隐藏地图上的要素。
map.addLayer({
'id': 'indoor',
'source': 'indoor',
'source-layer': ...
...
});
map.setFilter('indoor', ['==', 'level', '2']);发布于 2020-04-19 01:54:08
看看indoorequal前端,基于mapbox来显示室内楼层。
https://stackoverflow.com/questions/36584477
复制相似问题