Search code examples
javascriptgoogle-mapszoominggoogle-maps-markersmarkerclusterer

markerClusterer on click zoom


I just added a MarkerClusterer to my google map. It works perfectly fine.

I am just wondering if there is any way of adjusting the zoom-in behaviour when the cluster is clicked. I would like to change the zoom level if possible.

Is there any way of achieving this?

Thanks


Solution

  • I modified the clusterclick event as suggested:

    /**
    * Triggers the clusterclick event and zoom's if the option is set.
    */
    ClusterIcon.prototype.triggerClusterClick = function() {
    var markerClusterer = this.cluster_.getMarkerClusterer();
    
    // Trigger the clusterclick event.
    google.maps.event.trigger(markerClusterer, 'clusterclick', this.cluster_);
    
    if (markerClusterer.isZoomOnClick()) {
    // Zoom into the cluster.
    // this.map_.fitBounds(this.cluster_.getBounds());
    
    // modified zoom in function
    this.map_.setZoom(markerClusterer.getMaxZoom()+1);
    
     }
    };
    

    It works great! Thanks a lot