From c001bfb5f6c0000d5e7ef063188f562538bc8291 Mon Sep 17 00:00:00 2001 From: danzel Date: Tue, 11 Sep 2012 15:11:15 +1200 Subject: [PATCH] Make this a forwards loop so that a clear+re-add creates the same clusters --- src/MarkerClusterGroup.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 71eff4d28..8160a8178 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -227,7 +227,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ this._generateInitialClusters(); } - for (var i = this._needsClustering.length - 1; i >= 0; i--) { + for (var i = 0, l = this._needsClustering.length; i < l; i++) { this._addLayer(this._needsClustering[i], this._maxZoom); } this._needsClustering = []; @@ -417,7 +417,6 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ var parent = closest.__cluster || this._topClusterLevel; //Create new cluster with these 2 in it - console.log('creating new cluster with 2 markers at zoom ' + zoom); var newCluster = new L.MarkerCluster(this, zoom, closest, layer); gridClusters[zoom].addObject(newCluster, this._map.project(newCluster._cLatLng, zoom)); @@ -451,7 +450,6 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ //Merge and split any existing clusters that are too big or small _mergeSplitClusters: function () { - console.log('mergesplit ' + this._zoom + ' -> ' + map._zoom); if (this._zoom < this._map._zoom) { //Zoom in, split this._animationStart(); //Remove clusters now off screen