Skip to content

Commit

Permalink
Merge pull request Esri#1211 from Esri/fix-875-1196
Browse files Browse the repository at this point in the history
Fix bugs with feature layer setWhere
  • Loading branch information
gavinr authored Jul 9, 2020
2 parents 710ac1d + 043f41d commit 80adc6d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Layers/FeatureLayer/FeatureGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export var FeatureGrid = Layer.extend({
Util.setOptions(this, options);
},

onAdd: function () {
onAdd: function (map) {
this._cells = {};
this._activeCells = {};
this._resetView();
Expand Down
16 changes: 15 additions & 1 deletion src/Layers/FeatureLayer/FeatureManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export var FeatureManager = FeatureGrid.extend({
_requestFeatures: function (bounds, coords, callback) {
this._activeRequests++;

var originalWhere = this.options.where;

// our first active request fires loading
if (this._activeRequests === 1) {
this.fire(
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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);
Expand Down

0 comments on commit 80adc6d

Please sign in to comment.