+
+ this.do_clustering();
+ },
+
+ do_clustering: function()
+ {
+ this.markerCluster = new MarkerClusterer(this.map, this.markers, {zoomOnClick: false});
+ this.markerCluster.setIgnoreHidden(true);
+ google.maps.event.addListener(this.markerCluster, "clusterclick", function (cluster) {
+ var cluster_markers = cluster.getMarkers();
+ var bounds = new google.maps.LatLngBounds();
+ $.each(cluster_markers, function(i, marker){
+ bounds.extend(marker.getPosition());
+ });
+ //map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
+ this.map.fitBounds(bounds);
+ });
+ //now fit the map to the bounds
+ this.map.fitBounds(this.bounds);
+ // Fix the zoom of fitBounds function, it's too close when there is only 1 marker
+ if (this.markers.length==1) {
+ this.map.setZoom(this.map.getZoom()-4);
+ }