[ol.Tile] add a isLoaded function
This commit is contained in:
@@ -24,6 +24,12 @@ ol.Tile = function(url, bounds) {
|
|||||||
*/
|
*/
|
||||||
this.bounds_ = bounds;
|
this.bounds_ = bounds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.loaded_ = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {HTMLImageElement}
|
* @type {HTMLImageElement}
|
||||||
@@ -77,6 +83,7 @@ ol.Tile.prototype.getImg = function() {
|
|||||||
* @param {goog.events.BrowserEvent} evt Event.
|
* @param {goog.events.BrowserEvent} evt Event.
|
||||||
*/
|
*/
|
||||||
ol.Tile.prototype.handleImageLoad = function(evt) {
|
ol.Tile.prototype.handleImageLoad = function(evt) {
|
||||||
|
this.loaded_ = true;
|
||||||
this.events_.triggerEvent('load');
|
this.events_.triggerEvent('load');
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -88,6 +95,14 @@ ol.Tile.prototype.handleImageError = function(evt) {
|
|||||||
this.events_.triggerEvent('error');
|
this.events_.triggerEvent('error');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the tile loaded already?
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
ol.Tile.prototype.isLoaded = function() {
|
||||||
|
return this.loaded_;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ describe("ol.Tile", function() {
|
|||||||
tile.handleImageLoad();
|
tile.handleImageLoad();
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
it("sets the loaded flag", function() {
|
||||||
|
tile.handleImageLoad();
|
||||||
|
expect(tile.isLoaded()).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("handle image error", function() {
|
describe("handle image error", function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user