diff --git a/dist/leaflet.markercluster-src.js b/dist/leaflet.markercluster-src.js index 2c4a3e632..0f02a59a9 100644 --- a/dist/leaflet.markercluster-src.js +++ b/dist/leaflet.markercluster-src.js @@ -190,7 +190,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ //If we aren't on the map yet, just blow away the markers we know of if (!this._map) { this._needsClustering = []; - return this; + this._gridClusters = undefined; + this._gridUnclustered = undefined; + // return this; } if (this._unspiderfy) { @@ -204,8 +206,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ } } - //Reset _topClusterLevel and the DistanceGrids - this._generateInitialClusters(); + if (this._map) { + //Reset _topClusterLevel and the DistanceGrids + this._generateInitialClusters(); + } return this; }, diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index c4affab81..f92745dc1 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -183,7 +183,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ //If we aren't on the map yet, just blow away the markers we know of if (!this._map) { this._needsClustering = []; - return this; + this._gridClusters = undefined; + this._gridUnclustered = undefined; + // return this; } if (this._unspiderfy) { @@ -197,8 +199,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ } } - //Reset _topClusterLevel and the DistanceGrids - this._generateInitialClusters(); + if (this._map) { + //Reset _topClusterLevel and the DistanceGrids + this._generateInitialClusters(); + } return this; },