Skip to content

Commit

Permalink
rounded zoom to work with fractional zoom levels
Browse files Browse the repository at this point in the history
  • Loading branch information
Egon Steiner committed Mar 30, 2015
1 parent a1e0628 commit 6e35cf7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/MarkerClusterGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},

Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 6e35cf7

Please sign in to comment.