Fix child counting bug

This commit is contained in:
danzel
2012-07-20 16:03:14 +12:00
parent fb80032942
commit a944d7de44
+8 -7
View File
@@ -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;