本文介绍了使用Mapbox-gl-js通过JSON属性过滤聚类点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过切换列表来过滤符号来使用mapbox-gl-js过滤聚类点( https://www.mapbox.com/mapbox-gl-js/example/filter-markers/)?

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/)?

目标是构建这样的功能( https://www.mapbox.com/mapbox.js/example/v1.0.0/filtering-marker-clusters/)

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

推荐答案

GeoJSON集群发生在级别,因此,如果要过滤集群中的数据,则必须过滤GeoJSON本身,然后使用过滤后的数据更新源.map.getSource('sourceName').setData(filteredData)

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)

这是 jsfiddle 展示的功能

免责声明:我在Mapbox工作

disclaimer: I work at Mapbox

这篇关于使用Mapbox-gl-js通过JSON属性过滤聚类点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 10:32