[Pkg-javascript-commits] [leaflet-markercluster] 140/479: Add clearLayers implementation. Refs #26

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:21 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 755180b753ce3d00ce5996d3b208231e6fd0e567
Author: danzel <danzel at localhost.geek.nz>
Date:   Thu Aug 2 10:16:02 2012 +1200

    Add clearLayers implementation. Refs #26
---
 src/MarkerClusterGroup.js | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 65ed7cb..417612e 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -63,6 +63,22 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		return this;
 	},
 
+	clearLayers: function () {
+		//Need our own special implementation as the LayerGroup one doesn't work for us
+
+		//Remove all the visible layers
+		for (var i in this._layers) {
+			if (this._layers.hasOwnProperty(i)) {
+				L.FeatureGroup.prototype.removeLayer.call(this, this._layers[i]);
+			}
+		}
+
+		//Reset _topClusterLevel
+		this._generateInitialClusters();
+
+		return this;
+	},
+
 	//Overrides FeatureGroup.onAdd
 	onAdd: function (map) {
 		L.FeatureGroup.prototype.onAdd.call(this, map);
@@ -70,6 +86,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		if (!this._topClusterLevel) {
 			this._generateInitialClusters();
 		}
+
 		this._map.on('zoomend', this._zoomEnd, this);
 		this._map.on('moveend', this._moveEnd, this);
 
@@ -199,6 +216,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 			currentZoom = this._map.getZoom();
 
 		this._topClusterLevel = this._clusterToMarkerCluster(this._needsClustering, maxZoom);
+		this._needsClustering = [];
 
 		//Generate to the top
 		while (minZoom < this._topClusterLevel._zoom) {

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