Skip to content
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

Feature request: get zoom level at which the marker is unclustered #193

Open
orangecoloured opened this issue Dec 10, 2021 · 7 comments
Open

Comments

@orangecoloured
Copy link

There's the getClusterExpansionZoom which gives the zoom level at which the existing cluster is breaking into more clusters/markers.

It would be handy to be able to zoom into a marker so it appears unclustered. The use case for this is when I select an entity related to the marker outside of the map and I need to focus on the marker in case it's out of bounds or clustered.

Or is there a way to do this with the existing methods?

@karldanninger
Copy link

Need this. @orangecoloured did you ever find a solution?

@orangecoloured
Copy link
Author

@karldanninger Sorry, I can't remember and I can't test that now.

@karldanninger
Copy link

I appreciate your quick reply, thank you! I have the coordinates of the point I'd like to zoom into, so I guess the not-so performant way to do this is:

  • pan to coordinate
  • zoom in one level, evaluate if point is exposed, repeat.

@JClackett
Copy link

Any updates on this? I'm using supercluster on the server and having to manually loop over each cluster to find its getClusterExpansionZoom value and add to the properties, so I know what zoom level to use when clicking on the cluster. would be ideal, and probably more performant if supercluster could just include this property automatically?

@12finger
Copy link

12finger commented Feb 1, 2024

yeah, that would be lovely!
a convenience func to retrieve the minimal zoom level for a given marker.

like so https://github.com/mapbox/supercluster/pull/205/files#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346R194

@andreimp1
Copy link

Any updates on this? I'm using supercluster on the server and having to manually loop over each cluster to find its getClusterExpansionZoom value and add to the properties, so I know what zoom level to use when clicking on the cluster. would be ideal, and probably more performant if supercluster could just include this property automatically?

You can loop through the clusters with a recursive function until you find your point (assuming you know it's coordinates) and remember the parent cluster of the point.
Then do getClusterExpansionZoom using the parent cluster(id) and that's the zoom level you need to have your point unclustered.
Not ideal but works perfectly.

@JClackett
Copy link

@andreimp1 that's exactly what I am doing indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants