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;