diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 545fdfe3..956d27f3 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -720,7 +720,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ } this._mergeSplitClusters(); - this._zoom = this._map._zoom; + this._zoom = Math.round(this._map._zoom); this._currentShownBounds = this._getExpandedVisibleBounds(); }, @@ -732,7 +732,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ var newBounds = this._getExpandedVisibleBounds(); this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, newBounds); - this._topClusterLevel._recursivelyAddChildrenToMap(null, this._map._zoom, newBounds); + this._topClusterLevel._recursivelyAddChildrenToMap(null, Math.round(this._map._zoom), newBounds); this._currentShownBounds = newBounds; return; @@ -858,21 +858,22 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ //Merge and split any existing clusters that are too big or small _mergeSplitClusters: function () { + var mapZoom = Math.round(this._map._zoom); //Incase we are starting to split before the animation finished this._processQueue(); - if (this._zoom < this._map._zoom && this._currentShownBounds.contains(this._getExpandedVisibleBounds())) { //Zoom in, split + if (this._zoom < mapZoom && this._currentShownBounds.contains(this._getExpandedVisibleBounds())) { //Zoom in, split this._animationStart(); //Remove clusters now off screen this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, this._getExpandedVisibleBounds()); - this._animationZoomIn(this._zoom, this._map._zoom); + this._animationZoomIn(this._zoom, mapZoom); - } else if (this._zoom > this._map._zoom) { //Zoom out, merge + } else if (this._zoom > mapZoom) { //Zoom out, merge this._animationStart(); - this._animationZoomOut(this._zoom, this._map._zoom); + this._animationZoomOut(this._zoom, mapZoom); } else { this._moveEnd(); }