From a944d7de441ce4d3690f06a39166285a3cf31f16 Mon Sep 17 00:00:00 2001 From: danzel Date: Fri, 20 Jul 2012 16:03:14 +1200 Subject: [PATCH] Fix child counting bug --- src/MarkerCluster.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js index 551532967..e3d1abbf9 100644 --- a/src/MarkerCluster.js +++ b/src/MarkerCluster.js @@ -87,6 +87,7 @@ L.MarkerCluster = L.Marker.extend({ if (!this._haveGeneratedChildClusters && this._canAcceptPosition(layer.getLatLng(), zoom)) { //Don't need to cluster it in as we haven't clustered this._addChild(layer); + this._childCount++; result = true; } else { for (var i = this._childClusters.length - 1; i >= 0; i--) { @@ -95,6 +96,7 @@ L.MarkerCluster = L.Marker.extend({ if (c._bounds.contains(layer.getLatLng()) || c._canAcceptPosition(layer.getLatLng(), zoom + 1)) { result = c._recursivelyAddLayer(layer, zoom + 1); if (result) { + this._childCount++; break; } } @@ -114,15 +116,14 @@ L.MarkerCluster = L.Marker.extend({ result = true; } } - - if (result) { - this._childCount++; - if (this._icon) { - this.setIcon(this._group.options.iconCreateFunction(this._childCount)); - } - } } + if (result) { + //if (!this._zoom) { //TODO: Enable this when i've tracked the weird bug + this.setIcon(this._group.options.iconCreateFunction(this._childCount)); + //} + this._recalculateBounds(); + } if (result === true) { if (this._icon) { result = this;