From 9ab9e66bc7a55c4cd6e776472471add5654b601c Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Wed, 8 Jul 2020 13:02:52 -0700 Subject: [PATCH 1/2] fix #875, fix #1196 --- src/Layers/FeatureLayer/FeatureGrid.js | 2 +- src/Layers/FeatureLayer/FeatureManager.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Layers/FeatureLayer/FeatureGrid.js b/src/Layers/FeatureLayer/FeatureGrid.js index 34ea20b50..a4559cc4a 100644 --- a/src/Layers/FeatureLayer/FeatureGrid.js +++ b/src/Layers/FeatureLayer/FeatureGrid.js @@ -44,7 +44,7 @@ export var FeatureGrid = Layer.extend({ Util.setOptions(this, options); }, - onAdd: function () { + onAdd: function (map) { this._cells = {}; this._activeCells = {}; this._resetView(); diff --git a/src/Layers/FeatureLayer/FeatureManager.js b/src/Layers/FeatureLayer/FeatureManager.js index 6dfff904d..e1beac882 100644 --- a/src/Layers/FeatureLayer/FeatureManager.js +++ b/src/Layers/FeatureLayer/FeatureManager.js @@ -133,6 +133,8 @@ export var FeatureManager = FeatureGrid.extend({ _requestFeatures: function (bounds, coords, callback) { this._activeRequests++; + const originalWhere = this.options.where; + // our first active request fires loading if (this._activeRequests === 1) { this.fire( @@ -153,6 +155,11 @@ export var FeatureManager = FeatureGrid.extend({ this.fire('drawlimitexceeded'); } + // the where changed while this request was being run so don't it. + if (this.options.where !== originalWhere) { + return; + } + // no error, features if (!error && featureCollection && featureCollection.features.length) { // schedule adding features until the next animation frame @@ -271,7 +278,11 @@ export var FeatureManager = FeatureGrid.extend({ pendingRequests--; - if (pendingRequests <= 0 && this._visibleZoom()) { + if ( + pendingRequests <= 0 && + this._visibleZoom() && + where === this.options.where // the where is still the same so use this one + ) { this._currentSnapshot = newSnapshot; // schedule adding features for the next animation frame Util.requestAnimFrame( @@ -289,6 +300,9 @@ export var FeatureManager = FeatureGrid.extend({ for (var i = this._currentSnapshot.length - 1; i >= 0; i--) { oldSnapshot.push(this._currentSnapshot[i]); } + + this._cache = {}; + for (var key in this._cells) { pendingRequests++; var coords = this._keyToCellCoords(key); From 99d6364e807ab2254d575352c2158cdaad6471f4 Mon Sep 17 00:00:00 2001 From: Patrick Arlt Date: Thu, 9 Jul 2020 09:31:14 -0700 Subject: [PATCH 2/2] Update src/Layers/FeatureLayer/FeatureManager.js Co-authored-by: Gavin Rehkemper --- src/Layers/FeatureLayer/FeatureManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Layers/FeatureLayer/FeatureManager.js b/src/Layers/FeatureLayer/FeatureManager.js index e1beac882..4c4214903 100644 --- a/src/Layers/FeatureLayer/FeatureManager.js +++ b/src/Layers/FeatureLayer/FeatureManager.js @@ -133,7 +133,7 @@ export var FeatureManager = FeatureGrid.extend({ _requestFeatures: function (bounds, coords, callback) { this._activeRequests++; - const originalWhere = this.options.where; + var originalWhere = this.options.where; // our first active request fires loading if (this._activeRequests === 1) {