From d1b1df7cae0b69144143e04c9058af0f2fac3797 Mon Sep 17 00:00:00 2001 From: danzel Date: Fri, 20 Jul 2012 09:15:02 +1200 Subject: [PATCH] A few small bug fixes and code tidy ups. Add/Remove marker (after clustering) should be all that is broken now. --- src/MarkerCluster.js | 10 ++-------- src/MarkerClusterGroup.js | 8 +++++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js index 351de283c..e84b14c6a 100644 --- a/src/MarkerCluster.js +++ b/src/MarkerCluster.js @@ -77,7 +77,7 @@ L.MarkerCluster = L.Marker.extend({ }, //Removes the given node from this marker cluster (or its child as required) - //Returns true if it (or its childCluster) removes the marker + //Returns true if it (or a child cluster) removes the marker _recursivelyRemoveChildMarker: function(layer) { var markers = this._markers, childClusters = this._childClusters, @@ -121,12 +121,6 @@ L.MarkerCluster = L.Marker.extend({ return false; }, - _recursivelyRemoveChildrenAndAddNowVisibleMarkers: function (bounds, depthToStartAt, depthToAnimateIn) { - this._recursively(bounds, depthToStartAt, 0, null, function (c) { - c._recursivelyRemoveChildrenFromMap(bounds, depthToAnimateIn - 1); - }); - }, - _recursivelyAnimateChildrenIn: function (bounds, center, depth) { this._recursively(bounds, 0, depth - 1, function (c) { @@ -162,7 +156,7 @@ L.MarkerCluster = L.Marker.extend({ c._recursivelyAnimateChildrenIn(bounds, c._group._map.latLngToLayerPoint(c.getLatLng()).round(), depthToAnimateIn); //TODO: depthToAnimateIn affects _isSingleParent, if there is a multizoom we may/may not be. - if (c._isSingleParent() /*&& depthToAnimateIn === 1*/) { //TODO: If we are the same as our parent, don't do an animation, just immediately appear + if (c._isSingleParent() && depthToAnimateIn === 1) { //TODO: If we are the same as our parent, don't do an animation, just immediately appear c.setOpacity(1); c._recursivelyRemoveChildrenFromMap(bounds, depthToAnimateIn - 1); //Immediately remove our children as we are replacing them. TODO previousBounds not bounds } else { diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 49ab22d6a..41031a13e 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -372,7 +372,7 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? { markers = c._markers, m; - if (c._isSingleParent()) { //Immediately add the new child and remove us + if (c._isSingleParent() && depthToDescend == 1) { //Immediately add the new child and remove us L.FeatureGroup.prototype.removeLayer.call(me, c); c._recursivelyAddChildrenToMap(null, depthToDescend, bounds); } else { @@ -386,7 +386,7 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? { for (i = markers.length - 1; i >= 0; i--) { m = markers[i]; if (!bounds.contains(m._latlng)) { - L.FeatureGroup.prototype.removeLayer.call(this, m); + L.FeatureGroup.prototype.removeLayer.call(me, m); } } @@ -448,7 +448,9 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? { setTimeout(function () { map._mapPane.className = map._mapPane.className.replace(' leaflet-cluster-anim', ''); - me._topClusterLevel._recursivelyRemoveChildrenAndAddNowVisibleMarkers(bounds, depthToStartAt, depthToAnimateIn); + me._topClusterLevel._recursively(bounds, depthToStartAt, 0, null, function (c) { + c._recursivelyRemoveChildrenFromMap(bounds, depthToAnimateIn - 1); + }); me._inZoomAnimation--; }, 250); }