From 818bdc411cede91793f781227e3aa5c253254283 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Tue, 24 Sep 2019 15:18:59 +0200 Subject: [PATCH] Handle empty source tiles and queue them properly --- src/ol/TileQueue.js | 8 +++++--- src/ol/source/VectorTile.js | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ol/TileQueue.js b/src/ol/TileQueue.js index 3bf20be359..bf9fb6e9cd 100644 --- a/src/ol/TileQueue.js +++ b/src/ol/TileQueue.js @@ -112,10 +112,12 @@ class TileQueue extends PriorityQueue { if (state === TileState.ABORT) { abortedTiles = true; } else if (state === TileState.IDLE && !(tileKey in this.tilesLoadingKeys_)) { - this.tilesLoadingKeys_[tileKey] = true; - ++this.tilesLoading_; - ++newLoads; tile.load(); + if (tile.getState() === TileState.LOADING) { + this.tilesLoadingKeys_[tileKey] = true; + ++this.tilesLoading_; + ++newLoads; + } } } if (newLoads === 0 && abortedTiles) { diff --git a/src/ol/source/VectorTile.js b/src/ol/source/VectorTile.js index 3c0c126a4c..e47f020893 100644 --- a/src/ol/source/VectorTile.js +++ b/src/ol/source/VectorTile.js @@ -236,15 +236,17 @@ class VectorTile extends UrlTile { empty = false; sourceTile.addEventListener(EventType.CHANGE, this.handleTileChange.bind(this)); sourceTile.load(); + } else { + sourceTile = null; } } else { empty = false; } covered = false; - if (!sourceTile) { + if (sourceTile === undefined) { return; } - if (sourceTile.getState() !== TileState.EMPTY && tile.getState() === TileState.IDLE) { + if (sourceTile !== null && tile.getState() === TileState.IDLE) { tile.loadingSourceTiles++; const key = listen(sourceTile, EventType.CHANGE, function() { const state = sourceTile.getState();