googlemaps / googlemaps/js-markerclusterer

SuperClusterAlgorithm: change in marker position does not update the clustering

Open
#606 6 comments 6 reactions 1 assignee Claimed by @amuramoto View on GitHub
triage me type: bug
Dominant language
TypeScript
Stars
293
Forks
104
Avg merge
3m
Merged PRs (30d)
18

Description

#### Environment details

OS type and version: /
Library version: 2.0.15

#### Steps to reproduce

1. Setup a map with markers and marker clusterer (eg. the sample found at https://developers.google.com/maps/documentation/javascript/marker-clustering)
2. Update the position of a marker using `markerObject.setPosition(new google.maps.LatLng(lat, lng));` in a way that should change the clustering
3. Trigger a rerender on the clusterer: `clusterer.render()` -> NOK, clustering is not updated, expected the clustering to update

I did some debugging and found that the issue is here: https://github.com/googlemaps/js-markerclusterer/blob/2ac332afb468a2346ee1a56976fa2bd2c8e89291/src/algorithms/supercluster.ts#L52-L59

Because `this.markers` and `input.markers` contains the same marker instances, `equal(input.markers, this.markers)` is always `true` even though a copy of the array is made. The change detection will only detect if markers are added or removed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.