Allow users to filter features before they are clustered. Some users may want this filtering to happen without transferring GeoJSON between the main thread and worker threads.
We can filter these within the GL JS codebase before passing them to supercluster
.
continued from https://github.com/mapbox/supercluster/issues/11
cc @mourner @lyzidiamond
@mourner any progress on this? i'm working with very large data sets and calling .setData
every time i want to filter is fairly taxing
any updates on this? Thanks.
This would be more than helpful. Concerning the syntax, would this be something in the likes of?
[
'all',
['match', ['get', 'category'], selectedCategories, true, false],
// On a side note, I don't know what the true and false at the end do exactly,
// I just took this from the examples
['has', 'point_count']
]
Another side note: the documentation for setFilter links to deprecated syntax https://www.mapbox.com/mapbox-gl-js/api#map#setfilter, but looking at the expression syntax it seems quite similar to me, no?
Would order be important? As in: any filters coming before the "has point count" filter would apply to anything symbol specific and anything after would apply to the cluster?
I'm trying to revive this:
https://github.com/mapbox/mapbox-gl-js/issues/7887#issuecomment-461803534
Any update on this one ? When working with huge data sets, might be very useful
@crow7m : Take a look at their answer to my ticket above, it's clear they are not really willing to work on this :(
I'm also looking forward to updates on this. I've just started using Mapbox and it would be really useful for my specific project.
In the meantime, does anyone have a link to an example of the work around? I'm trying to create filters based on the feature's properties for my clustered map. I see that it involves filtering manually and using setData, but is there an example out there of that?
No progress on this for soon 4 years? This would solve a lot of problems performance wise when filtering huge data-sets that are clustered. @mourner
I think with the clusterProperties
its now possible.
for the source
"clusterProperties": { "cluster_count": ["+", ["case", <yourFilterExpression>, 1, 0]] }
and for the layer
"filter": ["all", ["==", ["get", "cluster"], true], [">", ["get", "cluster_count"], 0]]
Update:
maybe not :-(
It works so far, but it shows cluster of one item (if there is only one unfiltered item)
Update2:
I now use this filter api. It works to also use the mapbox filter expression
https://github.com/mapbox/mapbox-gl-js/tree/master/src/style-spec/feature_filter
But yes, not nice to store the row geojson
Hi all, is there any news about this feature state?
@mourner @lucaswoj hi all, thanks for cool library , question, is there a plan to implement this in near feature ?? This is quite old issue. thank you for your time and great work
Yes, we plan to work on this soon since this is such a highly requested feature — stay tuned for news in the coming weeks!
@mourner : Since it's been a few weeks, are there any updates on this feature?
@mourner I am also interested in being able to apply filters on sources dynamically.
still nothing guys? this shouldn't be that hard... we have this bug on our website and apps for a really long time and had to explain all the time we can't fix it cause Mapbox is not willing to fix :/
Hi guys! Any aupdate? like I see this can not be implemented, (4 years of requesting).
@mourner @lucaswoj , hi hope all are doing well and healthy, small question, is there any approximate date for this so cool feature to be available to public? Thank you and stay healthy.
Hey friends, I took a stab at this at #9864 — please let me know if this works for your use case!
It's a minimal implementation, only allowing setting the initial filter when adding the source, but there seems to be workaround for that — e.g. removing and re-adding a source with different options, which should be fine performance-wise since we have to re-process the whole data anyway, and the file by the URL is already cached by the browser.
Hey friends, I took a stab at this at #9864 — please let me know if this works for your use case!
It's a minimal implementation, only allowing setting the initial filter when adding the source, but there seems to be workaround for that — e.g. removing and re-adding a source with different options, which should be fine performance-wise since we have to re-process the whole data anyway, and the file by the URL is already cached by the browser.
Hi @mourner , thanks for the effort, so just to make sure i got it correct, instead of heavy operations with data, we will be able to pass same data to source and just update the filter in order to get filtered results, and in order for clusters to redraw on the map, correct ? if so i guess it will be better than filtering the whole data set every time we want to filter and redraw clusters. Thanks for your time and effort.
Most helpful comment
Yes, we plan to work on this soon since this is such a highly requested feature — stay tuned for news in the coming weeks!