0

MarkerClusterer works well with numeric array, but have you tried to use it with object of markers? I mean associated array, because I keep all markers inside this kind of array. Only what comes to my mind is translate associated array to "unusual" array, but this solution looks like strange. I aware that probably is not possible, but maybe someone has workaround for it.

Sebastian Bochan
  • 37,348
  • 3
  • 49
  • 75
  • Note: javascript does not have associative arrays. It has sparse, numerically-indexed arrays, and objects. Somewhat confusingly, arrays may be given properties with `myArray.myProp` or `myArray['myProp']` syntax, neither of which makes an entry in the array itself. – Beetroot-Beetroot Jul 15 '13 at 21:08
  • I know that not have, but "associative array" can be achieved by object. – Sebastian Bochan Jul 16 '13 at 10:55
  • Sebastian. Only partially. There's a big difference between javascript arrays and objects; namely that arrays are inherently ordered (elements [0], [1], [2] etc), while an object's properties are completely unordered - they are an "orderless pool". – Beetroot-Beetroot Jul 16 '13 at 22:18

2 Answers2

1

You can add an array of markers to the MarkerClusterer, or you can add them individually (they don't have to be in an array). Add your markers to the MarkerClusterer as you create them and add them to your "associative" array/object.

See the addMarker method in the documentation

geocodezip
  • 158,664
  • 13
  • 220
  • 245
0

Google Maps API v3

MarkerClusterer(map:google.maps.Map, opt_markers:Array.<google.maps.Marker>, opt_options:Object)

Please note this: opt_markers:Array.

This means that you should only use an array! According to this, just send your object to normal, numerical, array.

RomanGor
  • 3,835
  • 2
  • 19
  • 26