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.
Asked
Active
Viewed 761 times
0
-
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 Answers
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.

geocodezip
- 158,664
- 13
- 220
- 245
-
Indeed it was the best solution, I should overlook this position in docs. Thank you;) – Sebastian Bochan Jul 15 '13 at 20:17
0
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
-
This is clear, so I prepare converter to array and it works, but I'm wondering if is better option ;) Anyway thank you;) – Sebastian Bochan Jul 15 '13 at 20:09
-