alex chen
alex chen

Reputation: 41

Filtering Clustered Points by JSON attributes using 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/)

Upvotes: 3

Views: 2037

Answers (1)

mollymerp
mollymerp

Reputation: 1602

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

Upvotes: 6

Related Questions