From 0ef7c40b8e1ae69ad9ca3e0f6eeca72ca9f72bf1 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Sat, 23 Apr 2022 11:57:22 +0100 Subject: [PATCH] do not reload if already loaded or loading --- src/ol/DataTile.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/ol/DataTile.js b/src/ol/DataTile.js index ecd9fc6509..a5a87dfdb5 100644 --- a/src/ol/DataTile.js +++ b/src/ol/DataTile.js @@ -75,21 +75,26 @@ class DataTile extends Tile { * @api */ load() { - this.state = TileState.LOADING; - this.changed(); + if (this.state == TileState.ERROR) { + this.state = TileState.IDLE; + } + if (this.state == TileState.IDLE) { + this.state = TileState.LOADING; + this.changed(); - const self = this; - this.loader_() - .then(function (data) { - self.data_ = data; - self.state = TileState.LOADED; - self.changed(); - }) - .catch(function (error) { - self.error_ = error; - self.state = TileState.ERROR; - self.changed(); - }); + const self = this; + this.loader_() + .then(function (data) { + self.data_ = data; + self.state = TileState.LOADED; + self.changed(); + }) + .catch(function (error) { + self.error_ = error; + self.state = TileState.ERROR; + self.changed(); + }); + } } }