From 17f32ab1f8a46856e828d6dec914999fdb826b73 Mon Sep 17 00:00:00 2001 From: danzel Date: Fri, 9 Nov 2012 15:53:21 +1300 Subject: [PATCH] When initially adding layers, skip layers that are already added. Fixes adding the same layer multiple times before adding the MarkerClusterGroup to the map. Refs #44 --- src/MarkerClusterGroup.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 850a937243..e6635b84a2 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -283,7 +283,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ } for (var i = 0, l = this._needsClustering.length; i < l; i++) { - this._addLayer(this._needsClustering[i], this._maxZoom); + var layer = this._needsClustering[i]; + if (layer.__parent) { + continue; + } + this._addLayer(layer, this._maxZoom); } this._needsClustering = [];