Resize the canvas when the tile size changes
This commit is contained in:
committed by
Tim Schaub
parent
89954ca5fc
commit
0381689fb6
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user