Filtering Clustered Points by JSON attributes using Mapbox-gl-js

跟風遠走 提交于 2019-12-14 03:53:39

问题


Is there way to filter clustered points using mapbox-gl-js by Filter symbols by toggling a list (https://www.mapbox.com/mapbox-gl-js/example/filter-markers/)?

The goal is to build functionality such as this (https://www.mapbox.com/mapbox.js/example/v1.0.0/filtering-marker-clusters/)


回答1:


The GeoJSON clustering happens at the source level, so if you want to filter data in the clusters, you will have to filter the GeoJSON itself and then update the source with the filtered data. map.getSource('sourceName').setData(filteredData)

here is a jsfiddle demonstrating the functionality

disclaimer: I work at Mapbox



来源:https://stackoverflow.com/questions/39002142/filtering-clustered-points-by-json-attributes-using-mapbox-gl-js

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