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