From 5128c9c9195dd59b7ee9b5d6841b70b3d7f34c67 Mon Sep 17 00:00:00 2001 From: danzel Date: Wed, 12 Sep 2012 17:49:48 +1200 Subject: [PATCH] Fix up bounds recalculation, previously if you removed a marker the bounds wouldn't change --- src/MarkerCluster.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js index 904e45576..fe5fad396 100644 --- a/src/MarkerCluster.js +++ b/src/MarkerCluster.js @@ -316,18 +316,13 @@ L.MarkerCluster = L.Marker.extend({ i; this._bounds = new L.LatLngBounds(); + delete this._wLatLng; for (i = markers.length - 1; i >= 0; i--) { - this._bounds.extend(markers[i].getLatLng()); + this._expandBounds(markers[i]); } for (i = childClusters.length - 1; i >= 0; i--) { - this._bounds.extend(childClusters[i]._bounds); - } - - if (this._childCount === 0) { - delete this._latlng; - } else { - this.setLatLng(this._wLatLng); + this._expandBounds(childClusters[i]); } },