From 89baa4aa01d2ab2d75a46648103868118ce999fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sat, 20 Nov 2021 17:26:38 +0100 Subject: [PATCH] Correctly set popover position in geographic example --- examples/geographic.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/geographic.js b/examples/geographic.js index 61ea219cd9..11c5df9504 100644 --- a/examples/geographic.js +++ b/examples/geographic.js @@ -63,10 +63,15 @@ map.on('moveend', function () { }); map.on('click', function (event) { + $(element).popover('dispose'); + const feature = map.getFeaturesAtPixel(event.pixel)[0]; if (feature) { const coordinate = feature.getGeometry().getCoordinates(); - popup.setPosition(coordinate); + popup.setPosition([ + coordinate[0] + Math.round(event.coordinate[0] / 360) * 360, + coordinate[1], + ]); $(element).popover({ container: element.parentElement, html: true, @@ -75,8 +80,6 @@ map.on('click', function (event) { placement: 'top', }); $(element).popover('show'); - } else { - $(element).popover('dispose'); } });