Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mapbox-gl-js

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

like image 569
alex chen Avatar asked Feb 11 '26 11:02

alex chen


1 Answers

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

like image 158
mollymerp Avatar answered Feb 17 '26 03:02

mollymerp