Resize the canvas when the tile size changes

This commit is contained in:
bill-chadwick
2015-02-04 22:47:50 +00:00
committed by Tim Schaub
parent 89954ca5fc
commit 0381689fb6

View File

@@ -70,6 +70,12 @@ ol.renderer.canvas.TileLayer = function(tileLayer) {
*/
this.renderedCanvasZ_ = NaN;
/**
* @private
* @type {number}
*/
this.renderedTileSize_ = NaN;
/**
* @private
* @type {ol.TileRange}
@@ -228,9 +234,11 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
context = this.context_;
if (this.canvasSize_[0] < canvasWidth ||
this.canvasSize_[1] < canvasHeight ||
this.renderedTileSize_ !== tilePixelSize ||
(this.canvasTooBig_ && (this.canvasSize_[0] > canvasWidth ||
this.canvasSize_[1] > canvasHeight))) {
// Canvas is too small, resize it. We never shrink the canvas, unless
// Canvas is too small or tileSize has changed, resize it.
// We never shrink the canvas, unless
// we know that the current canvas size exceeds the maximum size
canvas.width = canvasWidth;
canvas.height = canvasHeight;
@@ -257,6 +265,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
minY = tileRange.minY -
Math.floor((canvasTileRangeHeight - tileRange.getHeight()) / 2);
this.renderedCanvasZ_ = z;
this.renderedTileSize_ = tilePixelSize;
this.renderedCanvasTileRange_ = new ol.TileRange(
minX, minX + canvasTileRangeWidth - 1,
minY, minY + canvasTileRangeHeight - 1);