Skip to content

Commit

Permalink
Merge pull request openlayers#663 from twpayne/render-error-tiles-as-…
Browse files Browse the repository at this point in the history
…empty

Render error tiles as empty
  • Loading branch information
twpayne committed Apr 28, 2013
2 parents 65a2aef + c576b2a commit 5bfef28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/ol/imagetile.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ ol.ImageTile.prototype.handleImageError_ = function() {
* @private
*/
ol.ImageTile.prototype.handleImageLoad_ = function() {
this.state = ol.TileState.LOADED;
if (this.image_.naturalWidth && this.image_.naturalHeight) {
this.state = ol.TileState.LOADED;
} else {
this.state = ol.TileState.EMPTY;
}
this.unlistenImage_();
this.dispatchChangeEvent();
};
Expand Down
10 changes: 6 additions & 4 deletions src/ol/renderer/canvas/canvastilelayerrenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =

tile = tileSource.getTile(z, x, y, projection);
tileState = tile.getState();
if (tileState == ol.TileState.LOADED || tileState == ol.TileState.EMPTY) {
if (tileState == ol.TileState.LOADED ||
tileState == ol.TileState.EMPTY ||
tileState == ol.TileState.ERROR) {
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
continue;
} else if (tileState == ol.TileState.ERROR) {
continue;
}

allTilesLoaded = false;
Expand Down Expand Up @@ -335,7 +335,9 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
x = tileSize.width * (tile.tileCoord.x - canvasTileRange.minX);
y = tileSize.height * (canvasTileRange.maxY - tile.tileCoord.y);
tileState = tile.getState();
if (tileState == ol.TileState.EMPTY || !opaque) {
if (tileState == ol.TileState.EMPTY ||
tileState == ol.TileState.ERROR ||
!opaque) {
context.clearRect(x, y, tileSize.width, tileSize.height);
}
if (tileState == ol.TileState.LOADED) {
Expand Down

0 comments on commit 5bfef28

Please sign in to comment.