From d45e08d1974233d1b4d7cb166f128b17a637d352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sun, 1 May 2022 14:38:35 +0200 Subject: [PATCH] Fix icon offset for hitdetect image It only worked correctly with pixel ratio of 1 --- src/ol/render/canvas/ImageBuilder.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/ol/render/canvas/ImageBuilder.js b/src/ol/render/canvas/ImageBuilder.js index 0768333f0d..348c0aeb55 100644 --- a/src/ol/render/canvas/ImageBuilder.js +++ b/src/ol/render/canvas/ImageBuilder.js @@ -129,8 +129,8 @@ class CanvasImageBuilder extends CanvasBuilder { this.anchorY_ * this.imagePixelRatio_, Math.ceil(this.height_ * this.imagePixelRatio_), this.opacity_, - this.originX_, - this.originY_, + this.originX_ * this.imagePixelRatio_, + this.originY_ * this.imagePixelRatio_, this.rotateWithView_, this.rotation_, [ @@ -186,8 +186,8 @@ class CanvasImageBuilder extends CanvasBuilder { this.anchorY_ * this.imagePixelRatio_, Math.ceil(this.height_ * this.imagePixelRatio_), this.opacity_, - this.originX_, - this.originY_, + this.originX_ * this.imagePixelRatio_, + this.originY_ * this.imagePixelRatio_, this.rotateWithView_, this.rotation_, [ @@ -249,18 +249,16 @@ class CanvasImageBuilder extends CanvasBuilder { setImageStyle(imageStyle, opt_sharedData) { const anchor = imageStyle.getAnchor(); const size = imageStyle.getSize(); - const hitDetectionImage = imageStyle.getHitDetectionImage(); - const image = imageStyle.getImage(this.pixelRatio); const origin = imageStyle.getOrigin(); this.imagePixelRatio_ = imageStyle.getPixelRatio(this.pixelRatio); this.anchorX_ = anchor[0]; this.anchorY_ = anchor[1]; - this.hitDetectionImage_ = hitDetectionImage; - this.image_ = image; + this.hitDetectionImage_ = imageStyle.getHitDetectionImage(); + this.image_ = imageStyle.getImage(this.pixelRatio); this.height_ = size[1]; this.opacity_ = imageStyle.getOpacity(); - this.originX_ = origin[0] * this.imagePixelRatio_; - this.originY_ = origin[1] * this.imagePixelRatio_; + this.originX_ = origin[0]; + this.originY_ = origin[1]; this.rotateWithView_ = imageStyle.getRotateWithView(); this.rotation_ = imageStyle.getRotation(); this.scale_ = imageStyle.getScaleArray();