From de3f60861d2349751befa9995c0a896091306b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Wed, 10 Feb 2021 00:15:43 +0100 Subject: [PATCH] Fix hitdetection of icons with opacity < 1 Hit detection works by reading the pixel color, if the icon is not drawn with full opacity it won't work. --- src/ol/render/canvas/hitdetect.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/render/canvas/hitdetect.js b/src/ol/render/canvas/hitdetect.js index c907a736ed..0efda29a36 100644 --- a/src/ol/render/canvas/hitdetect.js +++ b/src/ol/render/canvas/hitdetect.js @@ -81,7 +81,7 @@ export function createHitDetectionImageData( } style.setText(undefined); const image = originalStyle.getImage(); - if (image) { + if (image && image.getOpacity() !== 0) { const imgSize = image.getImageSize(); if (!imgSize) { continue; @@ -106,8 +106,8 @@ export function createHitDetectionImageData( anchorXUnits: IconAnchorUnits.PIXELS, anchorYUnits: IconAnchorUnits.PIXELS, offset: image.getOrigin(), + opacity: 1, size: image.getSize(), - opacity: image.getOpacity(), scale: image.getScale(), rotation: image.getRotation(), rotateWithView: image.getRotateWithView(),