simplify popup positioning

This commit is contained in:
mike-000
2021-01-31 23:11:22 +00:00
committed by GitHub
parent 2d1f8af516
commit d85da12782

View File

@@ -98,7 +98,6 @@ const popup = new Overlay({
element: element,
positioning: 'bottom-center',
stopEvent: false,
offset: [0, -50],
});
map.addOverlay(popup);
@@ -109,8 +108,7 @@ map.on('click', function (evt) {
});
$(element).popover('dispose');
if (feature) {
const coordinates = feature.getGeometry().getCoordinates();
popup.setPosition(coordinates);
popup.setPosition(evt.coordinate);
$(element).popover({
placement: 'top',
html: true,
@@ -123,11 +121,11 @@ map.on('click', function (evt) {
// change mouse cursor when over marker
map.on('pointermove', function (e) {
if (e.dragging) {
$(element).popover('dispose');
return;
}
const pixel = map.getEventPixel(e.originalEvent);
const hit = map.hasFeatureAtPixel(pixel);
map.getTarget().style.cursor = hit ? 'pointer' : '';
});
// Close the popup when the map is moved
map.on('movestart', function () {
$(element).popover('dispose');
});