From ff686786e47339ba983aa288d87d538d731fae4f Mon Sep 17 00:00:00 2001 From: danzel Date: Mon, 30 Jul 2012 11:11:56 +1200 Subject: [PATCH] Support removing markers down to 0. --- src/MarkerCluster.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js index 9876845d0..a157df5ce 100644 --- a/src/MarkerCluster.js +++ b/src/MarkerCluster.js @@ -185,9 +185,9 @@ L.MarkerCluster = L.Marker.extend({ } markers.splice(i, 1); + this._childCount--; this._recalculateBounds(); - this._childCount--; if (!('_zoom' in this)) { this.setIcon(group.options.iconCreateFunction(this._childCount)); } @@ -425,7 +425,11 @@ L.MarkerCluster = L.Marker.extend({ this._bounds.extend(childClusters[i]._bounds); } - this.setLatLng(this._bounds.getCenter()); + if (this._childCount == 0) { + delete this._latlng; + } else { + this.setLatLng(this._bounds.getCenter()); + } },