Merge pull request #1757 from twpayne/interim-tiles-on-error
Add option to use interim tiles on tile errors
This commit is contained in:
@@ -539,6 +539,8 @@
|
||||
* (inclusive) at which this layer will be visible.
|
||||
* @property {number|undefined} maxResolution The maximum resolution
|
||||
* (exclusive) below which this layer will be visible.
|
||||
* @property {boolean|undefined} useInterimTilesOnError Use interim tiles on
|
||||
* error. Default is `true`.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ goog.require('ol.layer.Layer');
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.layer.TileProperty = {
|
||||
PRELOAD: 'preload'
|
||||
PRELOAD: 'preload',
|
||||
USE_INTERIM_TILES_ON_ERROR: 'useInterimTilesOnError'
|
||||
};
|
||||
|
||||
|
||||
@@ -51,3 +52,32 @@ goog.exportProperty(
|
||||
ol.layer.Tile.prototype,
|
||||
'setPreload',
|
||||
ol.layer.Tile.prototype.setPreload);
|
||||
|
||||
|
||||
/**
|
||||
* @return {boolean|undefined} Use interim tiles on error.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.layer.Tile.prototype.getUseInterimTilesOnError = function() {
|
||||
return /** @type {boolean|undefined} */ (
|
||||
this.get(ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR));
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.layer.Tile.prototype,
|
||||
'getUseInterimTilesOnError',
|
||||
ol.layer.Tile.prototype.getUseInterimTilesOnError);
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean|undefined} useInterimTilesOnError Use interim tiles on error.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.layer.Tile.prototype.setUseInterimTilesOnError =
|
||||
function(useInterimTilesOnError) {
|
||||
this.set(
|
||||
ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.layer.Tile.prototype,
|
||||
'setUseInterimTilesOnError',
|
||||
ol.layer.Tile.prototype.setUseInterimTilesOnError);
|
||||
|
||||
@@ -266,6 +266,11 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
|
||||
var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource,
|
||||
tilesToDrawByZ, getTileIfLoaded);
|
||||
|
||||
var useInterimTilesOnError = tileLayer.getUseInterimTilesOnError();
|
||||
if (!goog.isDef(useInterimTilesOnError)) {
|
||||
useInterimTilesOnError = true;
|
||||
}
|
||||
|
||||
var tmpExtent = ol.extent.createEmpty();
|
||||
var tmpTileRange = new ol.TileRange(0, 0, 0, 0);
|
||||
var childTileRange, fullyLoaded, tile, tileState, x, y;
|
||||
@@ -276,7 +281,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.LOADED ||
|
||||
tileState == ol.TileState.EMPTY ||
|
||||
tileState == ol.TileState.ERROR) {
|
||||
(tileState == ol.TileState.ERROR && !useInterimTilesOnError)) {
|
||||
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
|
||||
continue;
|
||||
}
|
||||
@@ -331,7 +336,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
|
||||
y = tilePixelSize * (canvasTileRange.maxY - tile.tileCoord.y);
|
||||
tileState = tile.getState();
|
||||
if (tileState == ol.TileState.EMPTY ||
|
||||
tileState == ol.TileState.ERROR ||
|
||||
(tileState == ol.TileState.ERROR && !useInterimTilesOnError) ||
|
||||
!opaque) {
|
||||
context.clearRect(x, y, tilePixelSize, tilePixelSize);
|
||||
}
|
||||
|
||||
@@ -122,6 +122,11 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame =
|
||||
var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource,
|
||||
tilesToDrawByZ, getTileIfLoaded);
|
||||
|
||||
var useInterimTilesOnError = tileLayer.getUseInterimTilesOnError();
|
||||
if (!goog.isDef(useInterimTilesOnError)) {
|
||||
useInterimTilesOnError = true;
|
||||
}
|
||||
|
||||
var tmpExtent = ol.extent.createEmpty();
|
||||
var tmpTileRange = new ol.TileRange(0, 0, 0, 0);
|
||||
var childTileRange, fullyLoaded, tile, tileState, x, y;
|
||||
@@ -133,8 +138,9 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame =
|
||||
if (tileState == ol.TileState.LOADED) {
|
||||
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
|
||||
continue;
|
||||
} else if (tileState == ol.TileState.ERROR ||
|
||||
tileState == ol.TileState.EMPTY) {
|
||||
} else if (tileState == ol.TileState.EMPTY ||
|
||||
(tileState == ol.TileState.ERROR &&
|
||||
!useInterimTilesOnError)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -200,6 +200,11 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame =
|
||||
var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource,
|
||||
tilesToDrawByZ, getTileIfLoaded);
|
||||
|
||||
var useInterimTilesOnError = tileLayer.getUseInterimTilesOnError();
|
||||
if (!goog.isDef(useInterimTilesOnError)) {
|
||||
useInterimTilesOnError = true;
|
||||
}
|
||||
|
||||
var allTilesLoaded = true;
|
||||
var tmpExtent = ol.extent.createEmpty();
|
||||
var tmpTileRange = new ol.TileRange(0, 0, 0, 0);
|
||||
@@ -214,8 +219,9 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame =
|
||||
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
|
||||
continue;
|
||||
}
|
||||
} else if (tileState == ol.TileState.ERROR ||
|
||||
tileState == ol.TileState.EMPTY) {
|
||||
} else if (tileState == ol.TileState.EMPTY ||
|
||||
(tileState == ol.TileState.ERROR &&
|
||||
!useInterimTilesOnError)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user