-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setFilter method for GeoJSONSource #10722
Comments
Thanks for the issue! It totally makes sense to add a |
Thanks so much, @mourner!! |
👋 @mourner, just wondering if you had a general timeline for when this might be implemented. Thank you! 🙏 |
@mourner as another year went by without support for filtering clustered layers, is this still considered as an idea worth implementing? Filtering functionality in Mapbox feels very incomplete due to this. |
This feature would be helpful |
This would be super helpful! |
@jaericson I worked a bit with Mapbox and I made this pull request adding a new method @mourner I don't know if this is sufficient and well done, but it does the job. |
Any progress on this? it's been.. a while |
Would really like this feature, no updates? |
Motivation
You can cluster a
GeoJSONSource
, but it's difficult to filter out source data because the layerfilter
expression applies to the clustered features. TheGeoJSONSource
has afilter
property, but it can only be specified on source initialization.To paint an illustrative example, let's say we have 50K features with a date property and as a user interacts with our app, we allow them to filter the clustered map to just show features in a certain date range. If the 50K features weren't clustered, we could just apply a
filter
to each layer we wanted to filter. But with the 50K features clustered, we either need to filter the source data ourselves and usesetData
or we need to remove the source and add it back with afilter
applied to it. The former requires source data regeneration on our end, and the latter results in a flash as the map removes all features from the old source and adds all features from the new source.Thanks for your consideration, and also open to alternative ideas! ❤️
Design Alternatives
Would it be possible to add a
setFilter
method to aGeoJSONSource
to allow for this workflow?Design
Currently, it looks like the
setData
workflow in ageojson_source
will kick off aloadData
, which checks to see if there is a filter, and if so, does adata.features.filter
. Since thissetData
workflow looks at thefilter
, it seems likesetFilter
could potentially be a subset of this workflow.Mock-Up
Concepts
Implementation
The text was updated successfully, but these errors were encountered: