[英]Mapbox GL JS Loop / Iterate through clustered geojson features
我在 mapbox 源上使用聚類,以 geojson 作為輸入(幾個特征)來合並符號層上的一些標記。
const source = {
type: 'geojson',
data: {
type: 'FeatureCollection',
features: [...]
},
cluster: true,
clusterRadius: 15
}
...
集群后,我需要源中所有集群的 clusterId。 在源 object 的數據屬性中我只能找到原始特征集合(沒有集群)
有人知道我如何遍歷所有集群以獲得 clusterIds 嗎? 我在僅包含集群的源 object 中找不到任何屬性。
提前致謝
沿着這些方向的東西應該起作用:
for (const cluster of map.querySourceFeatures({ id: 'mygeojson', filter: ['get', 'cluster'] })) {
console.log(cluster.properties.cluster_id);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.