-
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
See features in cluster #3318
Comments
@mourner Could we combo supercluster + concaveman + polylabel here? Supercluster to figure out the clusters, concaveman to generate a polygon geometry for each one, polylabel to reduce the resulting polygon to a single point for rendering. |
@jfirebaugh I think it's an overkill, and won't really solve the original issue. This needs a proper solution on the supercluster side, but it's not trivial — will think about it. |
@mourner Maybe I'm totally wrong, but if you will store the "starting points" for each cluster on z18 and pass them all the way to z0, then you will be able to make recalculation (on z18 level) on any zoom level you want and return all the containing points... This will (just) reduce the amount of points you need to "store" for each cluster in case there millions and will allow to return all if needed with simple calculations... Sorry if I'm wrong or solution is not the best...just an idea;) |
Addressing this with a clever technique on the Supercluster side in mapbox/supercluster#31. Now we just need to decide how to properly expose it in Mapbox GL JS API. |
Second part of the puzzle (paginated leaves retrieval) is here mapbox/supercluster#32 |
Could this enhancement lead to additional options for filtering on cluster layers besides |
@Brodingo no, this is a different feature. |
@mourner Whats the status? This feature is a make it or brake it for the app we are working on and if it pops up in a version not to far away in the future i will definitely switch back to mapbox. |
Any updates? |
I can't speak for Mapbox but I can tell you that it is possible to start experimenting with this feature now with production releases of mapbox-gl-js and supercluster libraries. If you create a clustered layer in mapbox and also create your own instance of supercluster with the same parameters, the two structures can be correlated with the cluster_id property which is now present on each cluster. You can specify custom data aggregation functions or use the get_leaves method on your own supercluster instance. If you want to style clusters with custom aggregation functions, I would imagine that it's relatively easy to build a supercluster layer and then add the result it as a geojson layer to your map dynamcially in order to make the cluster attributes available for style rules. It may be necessary to transform the supercluster object into something that looks more like GeoJSON to get this to work though. Until arbex is added and a style syntax is specified there really can't be any more integration work done than this. |
Actually I think we can add |
Thank you very much for this quick and thorough reply on a Friday evening :) I will look into the supercluster feature. |
Using the latest version of Supercluster with GL JS, below are two solutions you could use today, prior to updates making it into the latest GL JS APIs: |
@mourner Thanks! These two functions are mostly what I personally needed anyway. But don't forget as sure as you publish it, we will undoubtedly want to have custom property aggregation on heatmap layers as well! 😂 |
Was able to get this to work thanks to examples! |
Amazing examples, thank you @ryanbaumann |
@ryanbaumann i'm getting a problem with your implementation where the cluster_id being returned isn't found in the super cluster. any thoughts? edit: The supercluster version is 3.0.2, but 2.3.0 in your example |
@shkfnly make sure the version of supercluster you are using corresponds to the version built as a dependency of the version of mapbox-gl-js you are using. I believe the method by which cluster_id were assigned was changed at some point to be unique (vs unique within each zoom level) and the examples may no longer work. |
Is anyone using a successful workaround for issues of clustering and click events? We have an almost working click to expand cluster action, but it fails in certain conditions. Cluster click uses Looks like Supercluster 3.0.2 would fix it, but that introduces other issues as noted above. |
@jasonbell I think we should just update supercluster to 3.0.2 in GL JS — this shouldn't introduce any issues other than having to match version if you're using supercluster "outside" in the app logic. |
@mourner That sounds great. I was going to give that go this weekend to get past this roadblock. Is a new issue needed to track the dependency update? |
I just want to say that it is a real shame that @mourner and others have done all of this great and powerful work on supercluster and it remains better to work with clusters completely outside of mapbox-gl-js. I understand the desire to have feature parity across language libraries, but it is really holding back a powerful tool. We are doing a lot of neat stats visualizations using custom property aggregations, filtering, and introspection that supercluster eneables. Luckily in our case since the library is so efficient, we are able to do this in on the main thread in a duplicate dataset without too much trouble, but it would be great to somehow have an api for lower level access to the internal cluster. For many of us it doesn't mean a hill of beans to whether or not these features are ever added to the Unity SDK or whatever. |
@mourner Another user rallying for a Supercluster update. I just ran into a use case yesterday where I need the ability to get the features in a cluster. I am playing with mapboxgl-spiderifier but it is using a fork of mapbox-gl-js, which I would rather not use. The reason it was forked I believe is because it needed this exact feature. That is, to get features in a cluster (e.g. getChildren). My point data is very dense so I needed a "spidering" technique to help out. I'd rather not maintain two copies of Supercluster in my project. |
Any chance to get an e.t.a. for this feature? It's a while since it has been opened and there are a lot of similar ones opened. Having a separate thread running a copy of supercluster on the same dataset is really bad for both memory and performances. |
For those who are ReactJS lover. This is a solution to show the points at same location using spiderifier. This library detect if you're clicking on a cluster that have same points location or not. If yes, it will show a spiderifier. If no it will do zooming. |
Hey friends, can you check out the PR for this at #6829? Would love some feedback on it. |
Hello!
I know this question was asked several times already, but there is still no workaround!
Using clustering is the only solution in case you have a big amount of pins on map. Unfortunately Supercluster allows you only to "aggregate" points in clusters, but there is no way to return the features inside the cluster back. This makes current clustering algorithm useless for the end user. Simple example: ten points with the same location are clustered...or the ten points with slightly different locations are clustered - how can I get the list of points inside the cluster on click?
I do understand that potentially it can be millions of points inside the cluster...so I can suggest a few solutions:
Have a look at Leaflet Clustering (screenshot ) - it calculates the approximate bounds of the cluster - it can be the solution to do the same, at least developers will be able to query the DB to return the original points...
Or you can store the ID's of the original points in each cluster and even limit the number to 100 for example - in most cases it will be more then enough - devs can at least code something like "if num_of_points_in_cluster > 100, then Zoom In the map else return IDs"
Really hope you will be able to find ANY solution, though the current clustering algorithm is useless and potentially buggy...
The text was updated successfully, but these errors were encountered: