Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/MarkerClusterGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
L.extend(this, animate ? this._withAnimation : this._noAnimation);
// Remember which MarkerCluster class to instantiate (animated or not).
this._markerCluster = animate ? L.MarkerCluster : L.MarkerClusterNonAnimated;
//Set the initial clear layers count to 0
this._clearLayersCallCount = 0;
},

addLayer: function (layer) {
Expand Down Expand Up @@ -199,13 +201,17 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
l = layersArray.length,
offset = 0,
originalArray = true,
m;
m,
clearLayerIndexWhenStarted = this._clearLayersCallCount;

if (this._map) {
var started = (new Date()).getTime();
var process = L.bind(function () {
var start = (new Date()).getTime();
for (; offset < l; offset++) {
if (clearLayerIndexWhenStarted !== this._clearLayersCallCount) {
break;
}
if (chunked && offset % 200 === 0) {
// every couple hundred markers, instrument the time elapsed since processing started:
var elapsed = (new Date()).getTime() - start;
Expand Down Expand Up @@ -260,6 +266,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
}
}

if (clearLayerIndexWhenStarted !== this._clearLayersCallCount) {
return;
}

if (chunkProgress) {
// report progress and time elapsed:
chunkProgress(offset, l, (new Date()).getTime() - started);
Expand Down Expand Up @@ -419,6 +429,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
delete this._gridUnclustered;
}

++this._clearLayersCallCount;

if (this._noanimationUnspiderfy) {
this._noanimationUnspiderfy();
}
Expand Down