From 9fb345543a1fbc53bc3e811504c6ff4d8f40e170 Mon Sep 17 00:00:00 2001 From: danzel Date: Wed, 14 Nov 2012 09:58:22 +1300 Subject: [PATCH] Handle removeLayers([]) where some elements aren't in the MarkerClusterGroup --- src/MarkerClusterGroup.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index e6635b84a..b631968d4 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -156,6 +156,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ for (i = 0, l = layersArray.length; i < l; i++) { m = layersArray[i]; + + if (!m.__parent) { + continue; + } + this._removeLayer(m, true, true); if (m._icon) {