Merge pull request #3223 from tschaub/tilesize-change
Resize the canvas when the tile size changes.
This commit is contained in:
@@ -70,6 +70,12 @@ ol.renderer.canvas.TileLayer = function(tileLayer) {
|
|||||||
*/
|
*/
|
||||||
this.renderedCanvasZ_ = NaN;
|
this.renderedCanvasZ_ = NaN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.renderedTileSize_ = NaN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.TileRange}
|
* @type {ol.TileRange}
|
||||||
@@ -228,9 +234,11 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
|
|||||||
context = this.context_;
|
context = this.context_;
|
||||||
if (this.canvasSize_[0] < canvasWidth ||
|
if (this.canvasSize_[0] < canvasWidth ||
|
||||||
this.canvasSize_[1] < canvasHeight ||
|
this.canvasSize_[1] < canvasHeight ||
|
||||||
|
this.renderedTileSize_ !== tilePixelSize ||
|
||||||
(this.canvasTooBig_ && (this.canvasSize_[0] > canvasWidth ||
|
(this.canvasTooBig_ && (this.canvasSize_[0] > canvasWidth ||
|
||||||
this.canvasSize_[1] > canvasHeight))) {
|
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
|
// we know that the current canvas size exceeds the maximum size
|
||||||
canvas.width = canvasWidth;
|
canvas.width = canvasWidth;
|
||||||
canvas.height = canvasHeight;
|
canvas.height = canvasHeight;
|
||||||
@@ -257,6 +265,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
|
|||||||
minY = tileRange.minY -
|
minY = tileRange.minY -
|
||||||
Math.floor((canvasTileRangeHeight - tileRange.getHeight()) / 2);
|
Math.floor((canvasTileRangeHeight - tileRange.getHeight()) / 2);
|
||||||
this.renderedCanvasZ_ = z;
|
this.renderedCanvasZ_ = z;
|
||||||
|
this.renderedTileSize_ = tilePixelSize;
|
||||||
this.renderedCanvasTileRange_ = new ol.TileRange(
|
this.renderedCanvasTileRange_ = new ol.TileRange(
|
||||||
minX, minX + canvasTileRangeWidth - 1,
|
minX, minX + canvasTileRangeWidth - 1,
|
||||||
minY, minY + canvasTileRangeHeight - 1);
|
minY, minY + canvasTileRangeHeight - 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user