[Pkg-javascript-commits] [leaflet-markercluster] 11/479: Zooming out wasn't adding markers to the map that weren't previously visible, woops

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet-markercluster.

commit e40702346b2999887583d588a896bd54068fbc4d
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jul 13 10:57:41 2012 +1200

    Zooming out wasn't adding markers to the map that weren't previously visible, woops
---
 src/MarkerClusterGroup.js | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 276ff74..b85281e 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -72,7 +72,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		//Do the clusters (and their child unclustered ones) recursively for performance
 		for (i = 0; i < highestLevelClusters.length; i++) {
 			l = highestLevelClusters[i];
-			if (bounds.contains(l.getLatLng())) {
+			if (bounds.intersects(l._bounds)) {
 				l._recursivelyAddChildrenToMap(null, depth, bounds);
 			}
 		}
@@ -162,7 +162,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 				}
 			}
 
-			this._animationZoomOut(newState.clusters, depth);
+			this._animationZoomOut(newState.clusters, newState.unclustered, depth);
 		}
 	},
 
@@ -384,18 +384,27 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 			c._recursivelyAddChildrenToMap(null, depth, bounds);
 		}
 	},
-	_animationZoomOut: function (newClusters, depth) {
-		var bounds = this._getExpandedVisibleBounds();
+	_animationZoomOut: function (newClusters, newUnclustered, depth) {
+		var bounds = this._getExpandedVisibleBounds(),
+			i;
 
 		//Just add new and remove old from the map
-		for (var j = 0; j < newClusters.length; j++) {
-			var cl = newClusters[j];
+		for (i = 0; i < newClusters.length; i++) {
+			var cl = newClusters[i];
 
 			if (bounds.contains(cl._latlng)) {
 				cl._addToMap();
 			}
 			cl._recursivelyRemoveChildrenFromMap(depth);
 		}
+		//Add new markers
+		for (i = newUnclustered.length - 1; i >= 0; i--) {
+			var m = newUnclustered[i];
+			if (bounds.contains(m._latlng)) {
+				L.FeatureGroup.prototype.addLayer.call(this, m); //TODO Animate
+			}
+		}
+
 	}
 } : {
 
@@ -434,12 +443,13 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 			}, 250);
 		}, 0);
 	},
-	_animationZoomOut: function (newClusters, depth) {
+	_animationZoomOut: function (newClusters, newUnclustered, depth) {
 		var map = this._map,
-		    bounds = this._getExpandedVisibleBounds();
+		    bounds = this._getExpandedVisibleBounds(),
+		    i;
 
 		//Animate all of the markers in the clusters to move to their cluster center point
-		for (var i = 0; i < newClusters.length; i++) {
+		for ( i = 0; i < newClusters.length; i++) {
 			var c = newClusters[i];
 
 			c._recursivelyAnimateChildrenIn(this._map.latLngToLayerPoint(c.getLatLng()).round(), depth);
@@ -452,13 +462,19 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 
 			map._mapPane.className = map._mapPane.className.replace(' leaflet-cluster-anim', '');
 
-			for (var j = 0; j < newClusters.length; j++) {
-				var cl = newClusters[j];
+			for (i = 0; i < newClusters.length; i++) {
+				var cl = newClusters[i];
 				if (bounds.contains(cl._latlng)) {
 					cl._addToMap();
 				}
 				cl._recursivelyRemoveChildrenFromMap(depth);
 			}
+			for (i = newUnclustered.length - 1; i >= 0; i--) {
+				var m = newUnclustered[i];
+				if (bounds.contains(m._latlng)) {
+					L.FeatureGroup.prototype.addLayer.call(me, m); //TODO Animate
+				}
+			}
 			me._inZoomAnimation = false;
 		}, 250);
 	}

-- 
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