[Pkg-javascript-commits] [leaflet-markercluster] 217/479: working clearLayers

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:32 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 ac504d69f6b2d3b56f151d5c281fd37a8a1b88d5
Author: danzel <danzel at localhost.geek.nz>
Date:   Tue Sep 11 14:51:09 2012 +1200

    working clearLayers
---
 src/MarkerClusterGroup.js | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 8ad5c0e..71eff4d 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -35,8 +35,6 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		this._needsClustering = [];
 		//The bounds of the currently shown area (from _getExpandedVisibleBounds) Updated on zoom/move
 		this._currentShownBounds = null;
-
-		this._topClusterLevel = new L.MarkerCluster(this, -1);
 	},
 
 	addLayer: function (layer) {
@@ -184,16 +182,16 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 	clearLayers: function () {
 		//Need our own special implementation as the LayerGroup one doesn't work for us
 
-		if (this._unspiderfy) {
-			this._unspiderfy();
-		}
-
 		//If we aren't on the map yet, just blow away the markers we know of
 		if (!this._map) {
 			this._needsClustering = [];
 			return this;
 		}
 
+		if (this._unspiderfy) {
+			this._unspiderfy();
+		}
+
 		//Remove all the visible layers
 		for (var i in this._layers) {
 			if (this._layers.hasOwnProperty(i)) {
@@ -201,11 +199,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 			}
 		}
 
-		//Clear the DistanceGrids
-		this._gridClusters = { };
-		this._gridUnclustered = { };
-
-		//Reset _topClusterLevel
+		//Reset _topClusterLevel and the DistanceGrids
 		this._generateInitialClusters();
 
 		return this;
@@ -393,6 +387,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 			this._gridClusters[zoom] = new L.DistanceGrid(radius);
 			this._gridUnclustered[zoom] = new L.DistanceGrid(radius);
 		}
+
+		this._topClusterLevel = new L.MarkerCluster(this, -1);
 	},
 
 	//Zoom: Zoom to start adding at (Pass this._maxZoom to start at the bottom)

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