From 34eb38f1a7ed6ef1b8b71bffeceabb574e324f0c Mon Sep 17 00:00:00 2001 From: danzel Date: Mon, 3 Mar 2014 11:47:53 +1300 Subject: [PATCH] Fix getBounds when removeOutsideVisibleBounds: false is set. fixes #321 --- src/MarkerClusterGroup.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index bde4a8b5f4..4b77fbfcdc 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -324,12 +324,13 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ //Override FeatureGroup.getBounds as it doesn't work getBounds: function () { var bounds = new L.LatLngBounds(); + if (this._topClusterLevel) { bounds.extend(this._topClusterLevel._bounds); - } else { - for (var i = this._needsClustering.length - 1; i >= 0; i--) { - bounds.extend(this._needsClustering[i].getLatLng()); - } + } + + for (var i = this._needsClustering.length - 1; i >= 0; i--) { + bounds.extend(this._needsClustering[i].getLatLng()); } bounds.extend(this._nonPointGroup.getBounds());