Smaller canvas when rotating vector layers

This commit is contained in:
Tim Schaub
2018-11-15 11:37:45 +01:00
parent 26de43de0c
commit f90efac131
4 changed files with 7 additions and 26 deletions

View File

@@ -378,12 +378,8 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
// resize and clear
const canvas = context.canvas;
let width = Math.round(size[0] * pixelRatio);
let height = Math.round(size[1] * pixelRatio);
if (rotation) {
const size = Math.round(Math.sqrt(width * width + height * height));
width = height = size;
}
const width = Math.round(size[0] * pixelRatio);
const height = Math.round(size[1] * pixelRatio);
if (canvas.width != width || canvas.height != height) {
canvas.width = width;
canvas.height = height;
@@ -462,11 +458,6 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
canvas.style.opacity = opacity;
}
const canvasTransform = 'rotate(' + rotation + 'rad)';
if (canvasTransform !== canvas.style.transform) {
canvas.style.transform = canvasTransform;
}
return this.container_;
}