-
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 API for mutating a layer's filter #985
Comments
Here are a couple use-cases that would benefit from dynamic manipulation of layer filters. All of our use-cases involve large amounts of complex geometries, e.g., 10K polygons is our base test set but we expect to operate in the range of 10K to 100K polygons within the map at one time… possibly more depending on how things shake out.
|
Another option, since the filtering is turned into functions anyway (in feature-filter code), would it be possible to just pass in a filter JavaScript function? I suppose the same limitation will exist unless there is a mechanism to reevaluate the functions periodically or forcefully. This makes me think of AngularJS's "digest cycle". |
Thanks @robschley, that's very helpful. I've sketched out a basic implementation that follows the same pattern as |
To answer your question about JS functions as filters: there are two technical reasons why we don't do this. One is that the filters are evaluated on web workers, and functions can't be transferred from the main thread to a worker. The second is that we need to maintain parity with mapbox-gl-native. We're not going to embed a JS interpreter there, so that rules out supporting JS functions in the style specification itself, and it's not clear that we'd want to commit to supporting functions in whatever the "native" language is for each native SDK. |
@jfirebaugh Thanks for this, it's a super simple API. I tried it out this morning and it works but it has the same flicker problem as in #973. I pulled down the latest master and the |
@robschley Try latest master, it contains both changes. |
Performance should be pretty good after fe10ad4. |
Thanks @jfirebaugh. I did see a bit of a performance uptick but I haven't had a chance to really dig into it. |
From one I can figure out, filtering is async, since the filtering is happening on the web worker, but I can't see an event I can listen for to know when it is done. Running this only updates the map once or twice: for (var i=0; i<100; i++) {
map.setFilter('markers', ['>', 'index', i])
} |
@gmaclennan Can you open a separate ticket for async callbacks, and for the setFilter calls getting dropped if you think that's a bug? |
Requested in #755 (comment).
The text was updated successfully, but these errors were encountered: