markerClusterer on click zoom

There has been an update to the MarkerClusterer source code, allowing much easier access to the click event:

google.maps.event.addListener(markerCluster, 'clusterclick', function(cluster) {
    // your code here
});

where ‘markerCluster’ ist the MarkerCluster object.
Inside the function you may also access

cluster.getCenter();
cluster.getMarkers();
cluster.getSize();

I use this to switch to a different map type, as I use a custom tile set for easier overview on lower zoom levels:

map.setCenter(cluster.getCenter()); // zoom to the cluster center
map.setMapTypeId(google.maps.MapTypeId.ROADMAP); // switch map type
map.setOptions(myMapOptions); // apply some other map options (optional)

Regards
Jack

Leave a Comment