-
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
Add a filter option for GeoJSON sources #9864
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mourner This works fine, but is missing the ability to update the filter
dynamically. Without that, it becomes difficult to use it in many situations where data has to be filtered based on user input.
What do you think about adding a GeoJSONSource#setFilter
as well? Since the filtering is applied on the worker, there's the question of whether the worker source also needs to hold an unfiltered copy of the source data.
For geojson-vt, the filtering could be applied when retrieving a tile - making filter updates quite cheap. For supercluster, Im not sure that options would work.
@asheemmamoowala I've touched on this in my comment here #2613 (comment). Basically we only need source-level filtering for clustering use cases, because we have to do it prior to clustering (which needs to run on all of the data), and other use cases such as geojson-vt are covered with layer-level filtering. We could add |
Should this be restricted to #2613 (comment) suggests that:
But this would only work when using a geoJSON by URL, not GeoJSON data, where an application might also be updating the feature dynamically
This can be added in the future if necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go pending tests.
Reminder to @mourner that this PR just needs some tests |
like i understand there is no possibility to update the source filter, right? Only by removing and adding a new source is not a solution for me, because therefore i also need to remove an recreate all depening layers. |
Introduces a
filter
option to GeoJSON sources that allows filtering out features prior to processing (e.g. before clustering) with an expression. Closes #2613.Launch Checklist
@mapbox/map-design-team
@mapbox/static-apis
if this PR includes style spec API or visual changes (not sure if that's relevant to these teams since it only targets GeoJSON)mapbox-gl-js
changelog:<changelog>Add a filter option to GeoJSON sources.</changelog>