react-map-gl-cluster icon indicating copy to clipboard operation
react-map-gl-cluster copied to clipboard

Pass Features to the ClusterMarker component

Open jasonleehodges opened this issue 5 years ago • 2 comments

Is your feature request related to a problem? Please describe. The ClusterMarker component is only passed a few props - one of them being the count of points in the cluster so that it can be rendered as a label to the cluster. I have a need to click on that cluster and, in a separate pane, see a list of the points in that cluster. It would be nice to pass all the features in that cluster to the ClusterMarker so that they can be accessed. Then, to render the label, you simply need to show the length of the array of features.

Describe the solution you'd like Pass the features to the ClusterMarker component as a prop.

Describe alternatives you've considered I've tried accessing the supercluster directly through refs and doing a reverse lookup of the points based on their lat/long coordinates. However, this is really messy and the ref doesn't seem to update as I zoom into the map and the cluster breaks apart into smaller clusters. Seems it would be way easier and cleaner to pass the features directly as a prop.

jasonleehodges avatar Apr 03 '20 15:04 jasonleehodges

This is something I would really love to do as well – list the markers under one cluster. Would be an awesome feature!

mb8z avatar Apr 28 '20 19:04 mb8z

@Ancinek I ended up creating my own implementation of this supercluster feature using use-supercluster and I simply passed the supercluster to the custom marker along with the cluster id. By doing that I could call getLeaves() on the super cluster and pass it the cluster ID to get all the points in that cluster.

jasonleehodges avatar Apr 29 '20 04:04 jasonleehodges