From b50b287c92a157ebd17f21159af4add886d830d5 Mon Sep 17 00:00:00 2001 From: danzel Date: Thu, 20 Sep 2012 10:12:01 +1200 Subject: [PATCH] Fix #64 and add a testcase --- .../old-bugs/add-remove-before-addtomap.html | 63 +++++++++++++++++++ src/MarkerClusterGroup.js | 6 ++ 2 files changed, 69 insertions(+) create mode 100644 example/old-bugs/add-remove-before-addtomap.html diff --git a/example/old-bugs/add-remove-before-addtomap.html b/example/old-bugs/add-remove-before-addtomap.html new file mode 100644 index 0000000000..2de3a7f6f2 --- /dev/null +++ b/example/old-bugs/add-remove-before-addtomap.html @@ -0,0 +1,63 @@ + + + + Leaflet debug page + + + + + + + + + + + + + + + + + + +
+ Bug #64. Nothing should appear on the map.
+ + + + diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 1715665d75..be5fbb7815 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -94,6 +94,12 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ }, removeLayer: function (layer) { + + if (!this._map) { + this._arraySplice(this._needsClustering, layer); + return this; + } + if (!layer.__parent) { return this; }