working clearLayers

This commit is contained in:
danzel
2012-09-11 14:51:09 +12:00
parent fa4d9913f6
commit ac504d69f6
+7 -11
View File
@@ -35,8 +35,6 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
this._needsClustering = [];
//The bounds of the currently shown area (from _getExpandedVisibleBounds) Updated on zoom/move
this._currentShownBounds = null;
this._topClusterLevel = new L.MarkerCluster(this, -1);
},
addLayer: function (layer) {
@@ -184,16 +182,16 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
clearLayers: function () {
//Need our own special implementation as the LayerGroup one doesn't work for us
if (this._unspiderfy) {
this._unspiderfy();
}
//If we aren't on the map yet, just blow away the markers we know of
if (!this._map) {
this._needsClustering = [];
return this;
}
if (this._unspiderfy) {
this._unspiderfy();
}
//Remove all the visible layers
for (var i in this._layers) {
if (this._layers.hasOwnProperty(i)) {
@@ -201,11 +199,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
}
}
//Clear the DistanceGrids
this._gridClusters = { };
this._gridUnclustered = { };
//Reset _topClusterLevel
//Reset _topClusterLevel and the DistanceGrids
this._generateInitialClusters();
return this;
@@ -393,6 +387,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
this._gridClusters[zoom] = new L.DistanceGrid(radius);
this._gridUnclustered[zoom] = new L.DistanceGrid(radius);
}
this._topClusterLevel = new L.MarkerCluster(this, -1);
},
//Zoom: Zoom to start adding at (Pass this._maxZoom to start at the bottom)