Update build

This commit is contained in:
danzel
2013-04-26 09:59:28 +12:00
parent e7e1d5391f
commit 6fda9a206f
2 changed files with 28 additions and 11 deletions
+27 -10
View File
@@ -48,6 +48,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
this._inZoomAnimation = 0;
this._needsClustering = [];
this._needsRemoving = []; //Markers removed while we aren't on the map need to be kept track of
//The bounds of the currently shown area (from _getExpandedVisibleBounds) Updated on zoom/move
this._currentShownBounds = null;
},
@@ -101,7 +102,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
removeLayer: function (layer) {
if (!this._map) {
this._arraySplice(this._needsClustering, layer);
if (!this._arraySplice(this._needsClustering, layer) && this.hasLayer(layer)) {
this._needsRemoving.push(layer);
}
return this;
}
@@ -269,12 +272,18 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
return false;
}
if (this._needsClustering.length > 0) {
var anArray = this._needsClustering;
for (var i = anArray.length - 1; i >= 0; i--) {
if (anArray[i] === layer) {
return true;
}
var i, anArray = this._needsClustering;
for (i = anArray.length - 1; i >= 0; i--) {
if (anArray[i] === layer) {
return true;
}
}
anArray = this._needsRemoving;
for (i = anArray.length - 1; i >= 0; i--) {
if (anArray[i] === layer) {
return false;
}
}
@@ -322,13 +331,20 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
//Overrides FeatureGroup.onAdd
onAdd: function (map) {
this._map = map;
var i, l, layer;
if (!this._gridClusters) {
this._generateInitialClusters();
}
for (var i = 0, l = this._needsClustering.length; i < l; i++) {
var layer = this._needsClustering[i];
for (i = 0, l = this._needsRemoving.length; i < l; i++) {
layer = this._needsRemoving[i];
this._removeLayer(layer);
}
this._needsRemoving = [];
for (i = 0, l = this._needsClustering.length; i < l; i++) {
layer = this._needsClustering[i];
if (layer.__parent) {
continue;
}
@@ -336,6 +352,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
}
this._needsClustering = [];
this._map.on('zoomend', this._zoomEnd, this);
this._map.on('moveend', this._moveEnd, this);
@@ -384,7 +401,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
for (var i = anArray.length - 1; i >= 0; i--) {
if (anArray[i] === obj) {
anArray.splice(i, 1);
return;
return true;
}
}
},
+1 -1
View File
File diff suppressed because one or more lines are too long