Correctly set popover position in geographic example

This commit is contained in:
Maximilian Krög
2021-11-20 17:26:38 +01:00
parent 036d9bf310
commit 89baa4aa01
+6 -3
View File
@@ -63,10 +63,15 @@ map.on('moveend', function () {
}); });
map.on('click', function (event) { map.on('click', function (event) {
$(element).popover('dispose');
const feature = map.getFeaturesAtPixel(event.pixel)[0]; const feature = map.getFeaturesAtPixel(event.pixel)[0];
if (feature) { if (feature) {
const coordinate = feature.getGeometry().getCoordinates(); const coordinate = feature.getGeometry().getCoordinates();
popup.setPosition(coordinate); popup.setPosition([
coordinate[0] + Math.round(event.coordinate[0] / 360) * 360,
coordinate[1],
]);
$(element).popover({ $(element).popover({
container: element.parentElement, container: element.parentElement,
html: true, html: true,
@@ -75,8 +80,6 @@ map.on('click', function (event) {
placement: 'top', placement: 'top',
}); });
$(element).popover('show'); $(element).popover('show');
} else {
$(element).popover('dispose');
} }
}); });