Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Commit

Permalink
Update markerclusterer.js: recentering the map after click on the clu…
Browse files Browse the repository at this point in the history
…ster (#505)

Fixes the bug when map is sometimes doesn't proper recenter. 
Center map to the the bounds of all markers inside a cluster.
  • Loading branch information
markymcfly authored and amuramoto committed Sep 19, 2019
1 parent 0178402 commit f4c2cc7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions markerclusterer/src/markerclusterer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1059,14 +1059,16 @@ function ClusterIcon(cluster, styles, opt_padding) {
* Triggers the clusterclick event and zoom's if the option is set.
*/
ClusterIcon.prototype.triggerClusterClick = function() {
var markerClusterer = this.cluster_.getMarkerClusterer();
var clusterBounds = this.cluster_.getBounds();
var markerClusterer = this.cluster_.getMarkerClusterer();

// Trigger the clusterclick event.
google.maps.event.trigger(markerClusterer.map_, 'clusterclick', this.cluster_);

if (markerClusterer.isZoomOnClick()) {
// Zoom into the cluster.
this.map_.fitBounds(this.cluster_.getBounds());
this.map_.fitBounds(clusterBounds);
this.map_.setCenter(clusterBounds.getCenter());
}
};

Expand Down

0 comments on commit f4c2cc7

Please sign in to comment.