js-markerclusterer icon indicating copy to clipboard operation
js-markerclusterer copied to clipboard

MarkerClusterer with SuperClusterAlgorithm appears to de-duplicate markers with identical coordinates

Open kanwal-rimsha opened this issue 5 months ago • 1 comments

Environment details API: Maps JavaScript API - @googlemaps/markerclusterer

OS: macOS (Apple M3)

Library version: @googlemaps/markerclusterer (2.0.15) with google.maps.marker.AdvancedMarkerElement.

Summary When using MarkerClusterer with SuperClusterAlgorithm, it appears that multiple AdvancedMarkerElement instances that share the exact same coordinates are being treated as a single point. The resulting cluster icon shows a count of "1" instead of the total number of markers passed for that location.

This behavior is unexpected, as the library should cluster all provided markers. In our application, we have a side panel that lists the total number of entities (which is correct), but the map's visual cluster count is incorrect due to this apparent de-duplication, leading to a confusing user experience.

Steps to reproduce Initialize a Google Map.

Create an array of multiple google.maps.marker.AdvancedMarkerElement instances, ensuring at least two or more share the exact same latitude and longitude.

Initialize MarkerClusterer using the default SuperClusterAlgorithm.

Call markerClusterer.addMarkers() with the array of markers.

Observe the map. A cluster will form at the specified coordinate, but its count will be "1" instead of the actual number of markers at that location.

kanwal-rimsha avatar Jul 30 '25 16:07 kanwal-rimsha

Hi,

If it helps, I came across your issue while trying to troubleshoot an unrelated issue:

Are you able to reproduce your issue if you update multiple points in https://github.com/googlemaps/js-markerclusterer/blob/main/examples/trees.json to have identical coordinates

then run the dev server outlined at https://github.com/googlemaps/js-markerclusterer?tab=readme-ov-file#usage

I did that, and the markercluster count was the number of points in my trees.json.

skora-cpl avatar Sep 05 '25 19:09 skora-cpl