diff --git a/examples/icon.js b/examples/icon.js index 62e8a40e67..123049ed8a 100644 --- a/examples/icon.js +++ b/examples/icon.js @@ -56,7 +56,6 @@ const popup = new Overlay({ element: element, positioning: 'bottom-center', stopEvent: false, - offset: [0, -50], }); map.addOverlay(popup); @@ -66,8 +65,7 @@ map.on('click', function (evt) { return feature; }); if (feature) { - const coordinates = feature.getGeometry().getCoordinates(); - popup.setPosition(coordinates); + popup.setPosition(evt.coordinate); $(element).popover({ placement: 'top', html: true, @@ -81,11 +79,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'); +});