Move preload property default value into ol.renderer.Layer#manageTilePyramid

This commit is contained in:
Tom Payne
2014-02-24 21:25:43 +01:00
parent 28d0d82253
commit 8c665c0bb1
2 changed files with 8 additions and 7 deletions

View File

@@ -20,22 +20,19 @@ ol.layer.TileProperty = {
* @todo observable preload {number} the level to preload tiles up to * @todo observable preload {number} the level to preload tiles up to
*/ */
ol.layer.Tile = function(options) { ol.layer.Tile = function(options) {
goog.base(this, options); goog.base(this, options);
this.setPreload(
goog.isDef(options.preload) ? options.preload : 0);
}; };
goog.inherits(ol.layer.Tile, ol.layer.Layer); goog.inherits(ol.layer.Tile, ol.layer.Layer);
/** /**
* @return {number} Preload. * @return {number|undefined} Preload.
* @todo stability experimental * @todo stability experimental
*/ */
ol.layer.Tile.prototype.getPreload = function() { ol.layer.Tile.prototype.getPreload = function() {
return /** @type {number} */ (this.get(ol.layer.TileProperty.PRELOAD)); return /** @type {number|undefined} */ (
this.get(ol.layer.TileProperty.PRELOAD));
}; };
goog.exportProperty( goog.exportProperty(
ol.layer.Tile.prototype, ol.layer.Tile.prototype,

View File

@@ -249,7 +249,8 @@ ol.renderer.Layer.prototype.snapCenterToPixel =
* @param {ol.proj.Projection} projection Projection. * @param {ol.proj.Projection} projection Projection.
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @param {number} currentZ Current Z. * @param {number} currentZ Current Z.
* @param {number} preload Load low resolution tiles up to 'preload' levels. * @param {number|undefined} preload Load low resolution tiles up to 'preload'
* levels.
* @param {function(this: T, ol.Tile)=} opt_tileCallback Tile callback. * @param {function(this: T, ol.Tile)=} opt_tileCallback Tile callback.
* @param {T=} opt_this Object to use as `this` in `opt_tileCallback`. * @param {T=} opt_this Object to use as `this` in `opt_tileCallback`.
* @protected * @protected
@@ -266,6 +267,9 @@ ol.renderer.Layer.prototype.manageTilePyramid = function(
var tileQueue = frameState.tileQueue; var tileQueue = frameState.tileQueue;
var minZoom = tileGrid.getMinZoom(); var minZoom = tileGrid.getMinZoom();
var tile, tileRange, tileResolution, x, y, z; var tile, tileRange, tileResolution, x, y, z;
if (!goog.isDef(preload)) {
preload = 0;
}
for (z = currentZ; z >= minZoom; --z) { for (z = currentZ; z >= minZoom; --z) {
tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z); tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
tileResolution = tileGrid.getResolution(z); tileResolution = tileGrid.getResolution(z);