diff --git a/src/ol/Tile.js b/src/ol/Tile.js index 697e0633d3..838c592c2d 100644 --- a/src/ol/Tile.js +++ b/src/ol/Tile.js @@ -100,6 +100,7 @@ ol.Tile.prototype.getImg = function() { * @param {goog.events.BrowserEvent} evt Event. */ ol.Tile.prototype.handleImageLoad = function(evt) { + this.loading_ = false; this.loaded_ = true; this.events_.triggerEvent('load'); }; @@ -109,6 +110,7 @@ ol.Tile.prototype.handleImageLoad = function(evt) { * @param {goog.events.BrowserEvent} evt Event. */ ol.Tile.prototype.handleImageError = function(evt) { + this.loading_ = false; this.events_.triggerEvent('error'); }; @@ -120,6 +122,14 @@ ol.Tile.prototype.isLoaded = function() { return this.loaded_; }; +/** + * Is the tile being loaded? + * @return {boolean} + */ +ol.Tile.prototype.isLoading = function() { + return this.loading_; +}; + /** * */ diff --git a/test/spec/ol/Tile.test.js b/test/spec/ol/Tile.test.js index 440efdf3a4..554560f617 100644 --- a/test/spec/ol/Tile.test.js +++ b/test/spec/ol/Tile.test.js @@ -42,6 +42,11 @@ describe("ol.Tile", function() { tile.handleImageLoad(); expect(tile.isLoaded()).toBeTruthy(); }); + it("unsets the loading flag", function() { + tile.loading_ = true; + tile.handleImageLoad(); + expect(tile.isLoading()).toBeFalsy(); + }); }); describe("handle image error", function() { @@ -56,5 +61,10 @@ describe("ol.Tile", function() { tile.handleImageError(); expect(spy).toHaveBeenCalled(); }); + it("unsets the loading flag", function() { + tile.loading_ = true; + tile.handleImageError(); + expect(tile.isLoading()).toBeFalsy(); + }); }); });