From 28c40fe93e4649aec3d5475fb626220a9fc06fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sun, 4 Jul 2021 14:32:36 +0200 Subject: [PATCH] getImage is always called with valid pixelRatio --- src/ol/style/RegularShape.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ol/style/RegularShape.js b/src/ol/style/RegularShape.js index 969790c64d..944a602458 100644 --- a/src/ol/style/RegularShape.js +++ b/src/ol/style/RegularShape.js @@ -225,19 +225,19 @@ class RegularShape extends ImageStyle { * @api */ getImage(pixelRatio) { - if (!this.canvas_[pixelRatio || 1]) { + let image = this.canvas_[pixelRatio]; + if (!image) { const renderOptions = this.createRenderOptions(); - const context = createCanvasContext2D( - renderOptions.size * pixelRatio || 1, - renderOptions.size * pixelRatio || 1 + renderOptions.size * pixelRatio, + renderOptions.size * pixelRatio ); + this.draw_(renderOptions, context, pixelRatio); - this.draw_(renderOptions, context, pixelRatio || 1); - - this.canvas_[pixelRatio || 1] = context.canvas; + image = context.canvas; + this.canvas_[pixelRatio] = image; } - return this.canvas_[pixelRatio || 1]; + return image; } /**