Create a new image when loading after an error
This commit is contained in:
@@ -22,6 +22,12 @@ ol.ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction, op
|
||||
|
||||
ol.Tile.call(this, tileCoord, state, opt_options);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {?string}
|
||||
*/
|
||||
this.crossOrigin_ = crossOrigin;
|
||||
|
||||
/**
|
||||
* Image URI
|
||||
*
|
||||
@@ -124,7 +130,14 @@ ol.ImageTile.prototype.handleImageLoad_ = function() {
|
||||
* @api
|
||||
*/
|
||||
ol.ImageTile.prototype.load = function() {
|
||||
if (this.state == ol.TileState.IDLE || this.state == ol.TileState.ERROR) {
|
||||
if (this.state == ol.TileState.ERROR) {
|
||||
this.state = ol.TileState.IDLE;
|
||||
this.image_ = new Image();
|
||||
if (this.crossOrigin_ !== null) {
|
||||
this.image_.crossOrigin = this.crossOrigin_;
|
||||
}
|
||||
}
|
||||
if (this.state == ol.TileState.IDLE) {
|
||||
this.state = ol.TileState.LOADING;
|
||||
this.changed();
|
||||
this.imageListenerKeys_ = [
|
||||
|
||||
@@ -68,11 +68,14 @@ describe('ol.ImageTile', function() {
|
||||
var tileLoadFunction = ol.source.Image.defaultImageLoadFunction;
|
||||
var tile = new ol.ImageTile(tileCoord, state, src, null, tileLoadFunction);
|
||||
|
||||
ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) {
|
||||
var key = ol.events.listen(tile, ol.events.EventType.CHANGE, function(event) {
|
||||
var state = tile.getState();
|
||||
if (state == ol.TileState.ERROR) {
|
||||
expect(state).to.be(ol.TileState.ERROR);
|
||||
expect(tile.image_.src).to.be(ol.ImageTile.blankImageUrl);
|
||||
expect(tile.image_).to.be.a(HTMLCanvasElement);
|
||||
ol.events.unlistenByKey(key);
|
||||
tile.load();
|
||||
expect(tile.image_).to.be.a(HTMLImageElement);
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user