[Pkg-javascript-commits] [leaflet-markercluster] 385/479: Fix places we were looping over this._layers to use this._featureGroup.eachLayer instead. Fixes child markers not being added to the map.

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:59 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 d032b53fea74b3a6fe1514cbd7ba4f6637225eb6
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jun 21 16:55:38 2013 +1200

    Fix places we were looping over this._layers to use this._featureGroup.eachLayer instead. Fixes child markers not being added to the map.
---
 src/MarkerClusterGroup.js | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 1f820a1..58c51b9 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -166,12 +166,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		}
 
 		//Update the icons of all those visible clusters that were affected
-		for (i in this._layers) {
-			m = this._layers[i];
-			if (m instanceof L.MarkerCluster && m._iconNeedsUpdate) {
-				m._updateIcon();
+		fg.eachLayer(function (c) {
+			if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
+				c._updateIcon();
 			}
-		}
+		});
 
 		this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
 
@@ -180,7 +179,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 	//Takes an array of markers and removes them in bulk
 	removeLayers: function (layersArray) {
-		var i, l, m;
+		var i, l, m,
+			fg = this._featureGroup;
 
 		if (!this._map) {
 			for (i = 0, l = layersArray.length; i < l; i++) {
@@ -198,8 +198,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 			this._removeLayer(m, true, true);
 
-			if (this._featureGroup.hasLayer(m)) {
-				this._featureGroup.removeLayer(m);
+			if (fg.hasLayer(m)) {
+				fg.removeLayer(m);
 				if (m.setOpacity) {
 					m.setOpacity(1);
 				}
@@ -209,12 +209,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		//Fix up the clusters and markers on the map
 		this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
 
-		for (i in this._layers) {
-			m = this._layers[i];
-			if (m instanceof L.MarkerCluster) {
-				m._updateIcon();
+		fg.eachLayer(function (c) {
+			if (c instanceof L.MarkerCluster) {
+				c._updateIcon();
 			}
-		}
+		});
 
 		return this;
 	},
@@ -824,18 +823,15 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 		});
 
 		this._forceLayout();
-		var j, n;
 
 		//Update opacities
 		me._topClusterLevel._recursivelyBecomeVisible(bounds, newZoomLevel);
 		//TODO Maybe? Update markers in _recursivelyBecomeVisible
-		for (j in me._layers) {
-			n = me._layers[j];
-
+		fg.eachLayer(function (n) {
 			if (!(n instanceof L.MarkerCluster) && n._icon) {
 				n.setOpacity(1);
 			}
-		}
+		});
 
 		//update the positions of the just added clusters/markers
 		me._topClusterLevel._recursively(bounds, previousZoomLevel, newZoomLevel, function (c) {

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