Google Maps and the MarkerClusterer solution

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,


9 thoughts on “Google Maps and the MarkerClusterer solution

    1. 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.


  1. 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 !!

    1. Sorry for this stupid question, i haved an error in my code, the function “init” was called twice…
      Thanks anyway.

  2. Hi,
    I have a listener in my map that intercept click on it and it add a marker. This event is fired also when i click on one of the marker created by markercluster.js.

    Do you know how can I intercept if the click was made on the map or on the markercluster icon?

  3. Hi,

    I would love to use this script, but i have a problem – i need to agregate markers not only by the density of them but also by the type of the marker – can any one poin me in some direction how to do it w/o inicializing 3 markerclusters ?

Leave a Reply to philip andrew Cancel reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s