Skip to content

Commit

Permalink
fix #875, fix #1196
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickarlt committed Jul 8, 2020
1 parent 542022a commit 9ab9e66
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++;

const 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 9ab9e66

Please sign in to comment.