[Pkg-javascript-commits] [leaflet-markercluster] 116/128: Pull minZoom fetching out to fix errors removing a MCG from a map while an animation is going on.
Jonas Smedegaard
dr at jones.dk
Sun Apr 16 06:26:09 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository leaflet-markercluster.
commit 162f15722e9d0e5ae576813ea8ac8f6a78617fc4
Author: danzel <dave at smartrak.co.nz>
Date: Tue Mar 7 09:57:00 2017 +1300
Pull minZoom fetching out to fix errors removing a MCG from a map while an animation is going on.
Refs #758
---
src/MarkerCluster.js | 10 +++++-----
src/MarkerClusterGroup.js | 14 +++++++-------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js
index 07121e4..7df16dd 100644
--- a/src/MarkerCluster.js
+++ b/src/MarkerCluster.js
@@ -241,8 +241,8 @@ L.MarkerCluster = L.Marker.extend({
);
},
- _recursivelyAnimateChildrenInAndAddSelfToMap: function (bounds, previousZoomLevel, newZoomLevel) {
- this._recursively(bounds, newZoomLevel, this._group._map.getMinZoom(),
+ _recursivelyAnimateChildrenInAndAddSelfToMap: function (bounds, mapMinZoom, previousZoomLevel, newZoomLevel) {
+ this._recursively(bounds, newZoomLevel, mapMinZoom,
function (c) {
c._recursivelyAnimateChildrenIn(bounds, c._group._map.latLngToLayerPoint(c.getLatLng()).round(), previousZoomLevel);
@@ -250,7 +250,7 @@ L.MarkerCluster = L.Marker.extend({
//As a hack we only do a animation free zoom on a single level zoom, if someone does multiple levels then we always animate
if (c._isSingleParent() && previousZoomLevel - 1 === newZoomLevel) {
c.clusterShow();
- c._recursivelyRemoveChildrenFromMap(bounds, previousZoomLevel); //Immediately remove our children as we are replacing them. TODO previousBounds not bounds
+ c._recursivelyRemoveChildrenFromMap(bounds, mapMinZoom, previousZoomLevel); //Immediately remove our children as we are replacing them. TODO previousBounds not bounds
} else {
c.clusterHide();
}
@@ -329,9 +329,9 @@ L.MarkerCluster = L.Marker.extend({
},
//exceptBounds: If set, don't remove any markers/clusters in it
- _recursivelyRemoveChildrenFromMap: function (previousBounds, zoomLevel, exceptBounds) {
+ _recursivelyRemoveChildrenFromMap: function (previousBounds, mapMinZoom, zoomLevel, exceptBounds) {
var m, i;
- this._recursively(previousBounds, this._group._map.getMinZoom() - 1, zoomLevel - 1,
+ this._recursively(previousBounds, mapMinZoom - 1, zoomLevel - 1,
function (c) {
//Remove markers at every level
for (i = c._markers.length - 1; i >= 0; i--) {
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 19049ec..c7479ec 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -913,7 +913,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
var newBounds = this._getExpandedVisibleBounds();
- this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, newBounds);
+ this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._map.getMinZoom(), this._zoom, newBounds);
this._topClusterLevel._recursivelyAddChildrenToMap(null, Math.round(this._map._zoom), newBounds);
this._currentShownBounds = newBounds;
@@ -1053,7 +1053,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
if (this._zoom < mapZoom && this._currentShownBounds.intersects(this._getExpandedVisibleBounds())) { //Zoom in, split
this._animationStart();
//Remove clusters now off screen
- this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, this._getExpandedVisibleBounds());
+ this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._map.getMinZoom(), this._zoom, this._getExpandedVisibleBounds());
this._animationZoomIn(this._zoom, mapZoom);
@@ -1177,14 +1177,14 @@ L.MarkerClusterGroup.include({
//Do nothing...
},
_animationZoomIn: function (previousZoomLevel, newZoomLevel) {
- this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel);
+ this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._map.getMinZoom(), previousZoomLevel);
this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
//We didn't actually animate, but we use this event to mean "clustering animations have finished"
this.fire('animationend');
},
_animationZoomOut: function (previousZoomLevel, newZoomLevel) {
- this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel);
+ this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._map.getMinZoom(), previousZoomLevel);
this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
//We didn't actually animate, but we use this event to mean "clustering animations have finished"
@@ -1276,7 +1276,7 @@ L.MarkerClusterGroup.include({
//Need to add markers for those that weren't on the map before but are now
this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds());
//Remove markers that were on the map before but won't be now
- this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel, this._getExpandedVisibleBounds());
+ this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._map.getMinZoom(), previousZoomLevel, this._getExpandedVisibleBounds());
},
_animationAddLayer: function (layer, newCluster) {
@@ -1317,7 +1317,7 @@ L.MarkerClusterGroup.include({
minZoom = this._map.getMinZoom();
//Animate all of the markers in the clusters to move to their cluster center point
- cluster._recursivelyAnimateChildrenInAndAddSelfToMap(bounds, previousZoomLevel + 1, newZoomLevel);
+ cluster._recursivelyAnimateChildrenInAndAddSelfToMap(bounds, minZoom, previousZoomLevel + 1, newZoomLevel);
var me = this;
@@ -1341,7 +1341,7 @@ L.MarkerClusterGroup.include({
}
} else {
cluster._recursively(bounds, newZoomLevel, minZoom, function (c) {
- c._recursivelyRemoveChildrenFromMap(bounds, previousZoomLevel + 1);
+ c._recursivelyRemoveChildrenFromMap(bounds, minZoom, previousZoomLevel + 1);
});
}
me._animationEnd();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git
More information about the Pkg-javascript-commits
mailing list