From 6dc3ce8a027e253d1ad89ae3056bfc0a0c929aef Mon Sep 17 00:00:00 2001 From: Adrien Grsmto Date: Tue, 20 May 2014 14:21:16 +0200 Subject: [PATCH 1/2] Add test case for a bug when calling removeLayers when spiderified --- example/old-bugs/remove-when-spiderfied.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/example/old-bugs/remove-when-spiderfied.html b/example/old-bugs/remove-when-spiderfied.html index 194973ac2..eb14f5547 100644 --- a/example/old-bugs/remove-when-spiderfied.html +++ b/example/old-bugs/remove-when-spiderfied.html @@ -19,7 +19,7 @@
-
+
Bug #54. Spiderfy the cluster then click the button. Should result in 2 markers right beside each other on the map.
Bug #53. Spiderfy the cluster then click the button. Spider lines remain on the map.
Bug #49. Spiderfy the cluster then click the second button. Spider lines remain on the map. Click the map to get an error. @@ -56,6 +56,9 @@ L.DomUtil.get('doit2').onclick = function () { markers.clearLayers(); }; + L.DomUtil.get('doit3').onclick = function () { + markers.removeLayers(markersList); + }; From 129cdf60e70793aa9431dcf4634bba507a8479e7 Mon Sep 17 00:00:00 2001 From: Adrien Grsmto Date: Tue, 20 May 2014 15:54:46 +0200 Subject: [PATCH 2/2] Bug fix + test for 6dc3 --- spec/suites/removeLayersSpec.js | 7 +++++++ src/MarkerClusterGroup.js | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/spec/suites/removeLayersSpec.js b/spec/suites/removeLayersSpec.js index 0ff840a60..8f24ecf12 100644 --- a/spec/suites/removeLayersSpec.js +++ b/spec/suites/removeLayersSpec.js @@ -57,6 +57,9 @@ markers[0].__parent.spiderfy(); + // We must wait for the spiderfy animation to timeout + clock.tick(200); + group.removeLayers(markers); expect(group.hasLayer(markers[0])).to.be(false); @@ -64,5 +67,9 @@ expect(group.hasLayer(markers[2])).to.be(false); expect(group.getLayers().length).to.be(0); + + group.on('spiderfied', function() { + expect(group._spiderfied).to.be(null); + }); }); }); \ No newline at end of file diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index ac5add87e..1cadda399 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -251,6 +251,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ fg = this._featureGroup, npg = this._nonPointGroup; + if (this._unspiderfy) { + this._unspiderfy(); + } + if (!this._map) { for (i = 0, l = layersArray.length; i < l; i++) { m = layersArray[i];