Hi everyone,
today I’ll be writing a small post about a problem that most people who write maps application deal with: add thousands of markers in you map. A known solution to manage your marker is GMarkerManager. However, today I read about the MarkerClusterer solution in GeoGoogleDevelopers Blog.
“MarkerClusterer collects markers into different clusters and displays the number of markers in each cluster with a label, creating new clusters as the map zoom level changes. The clustering algorithm is simple; for each new marker it sees, it either puts it inside a pre-existing cluster, or it creates a new cluster if the marker doesn’t lie within the bounds of any current cluster.”
The effect of using MarkerClusterer is shown in the picture below and library’s sample site:

The library works like magic. You just have to pass your array of markers to the MarkerClusterer constructor, and it ill take care of the rest. First, we have to import the MarkerClusterer JavaScript implementation file. Later, we create some markers, push into the array and call MarkerClusterer, as shown in the code snippet below.

It’s really awesome and straightfoward. Try it yourself.
See you,
–
Fernando

Do you know how to use MarkerClusterer in GWT? I have a GWT map and I really need to use this ! Thanks, Philip
Comment by philip andrew — May 25, 2009 @ 2:15 pm
Sorry philip, I don’t have too much experience in Google Maps API for GWT.
Maybe, if you have some way to use JavaScript manipulation for your map, the problem is solved.
[]’s
Fernando
Comment by nandokakimoto — May 25, 2009 @ 2:34 pm
i dont understand why when you create 300 markers the api displays 600 markers (sum of the marker’s values displayed) ??
thanks for your answer and sorry for my bad english !!
Comment by kentin — June 30, 2009 @ 2:17 pm
Sorry for this stupid question, i haved an error in my code, the function “init” was called twice…
Thanks anyway.
Bye
Comment by kentin — June 30, 2009 @ 3:16 pm
Hi, I have ported this to flash, if anybody wants the source it’s at
http://www.toruinteractive.com/stuff/MarkerClusterer_For_Flash.zip
I don’t do much open source development so I’m not sure where the best place to post the new source is. If anybody wants to take the code and put it in the appropriate place that would be great.
Sean
Comment by Sean Toru — July 2, 2009 @ 11:47 am