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

Use a Set of markers instead of an array

Open vicb opened this issue 2 years ago • 1 comments
trafficstars

The clusterer uses an array of markers:

https://github.com/googlemaps/js-markerclusterer/blob/9476b3a62399fd124c92ed74faae6943cf573ea4/src/markerclusterer.ts#L33

This is inefficient has the lib often scans the whole list (and by definition the list is big when you use the clusterer):

https://github.com/googlemaps/js-markerclusterer/blob/9476b3a62399fd124c92ed74faae6943cf573ea4/src/markerclusterer.ts#L104-L106

https://github.com/googlemaps/js-markerclusterer/blob/9476b3a62399fd124c92ed74faae6943cf573ea4/src/markerclusterer.ts#L125

switching to a Set would be much more efficient.

I could volunteer that code if using a Set is ok with the targeted list of supported browsers - let me know

vicb avatar May 21 '23 18:05 vicb

Input into any clusterer should NOT be based on Google Map Markers; which was a design flaw from the get-go as map markers should only be created for display in the map viewport - thus saving time and memory.

Input to a clusterer should be based on a "key" value which is associated with a latitude and longitude; in which case a Map would be ideal. Proof of such a concept is shown at: Creating data points vs creating Google map markers

bdcoder2 avatar Feb 06 '24 22:02 bdcoder2