supercluster icon indicating copy to clipboard operation
supercluster copied to clipboard

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

Open orangecoloured opened this issue 3 years ago • 7 comments

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?

orangecoloured avatar Dec 10 '21 13:12 orangecoloured

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

karldanninger avatar Aug 29 '22 13:08 karldanninger

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

orangecoloured avatar Aug 29 '22 13:08 orangecoloured

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.

karldanninger avatar Aug 29 '22 13:08 karldanninger

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?

JClackett avatar Oct 12 '23 11:10 JClackett

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

12finger avatar Feb 01 '24 03:02 12finger

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.

andreimp1 avatar Feb 28 '24 12:02 andreimp1

@andreimp1 that's exactly what I am doing indeed

JClackett avatar Feb 28 '24 12:02 JClackett