Merge pull request #11954 from ahocevar/simplify-icon-example

Simplify icon example
This commit is contained in:
Andreas Hocevar
2021-01-31 19:13:24 +01:00
committed by GitHub
+5 -7
View File
@@ -56,7 +56,6 @@ const popup = new Overlay({
element: element, element: element,
positioning: 'bottom-center', positioning: 'bottom-center',
stopEvent: false, stopEvent: false,
offset: [0, -50],
}); });
map.addOverlay(popup); map.addOverlay(popup);
@@ -66,8 +65,7 @@ map.on('click', function (evt) {
return feature; return feature;
}); });
if (feature) { if (feature) {
const coordinates = feature.getGeometry().getCoordinates(); popup.setPosition(evt.coordinate);
popup.setPosition(coordinates);
$(element).popover({ $(element).popover({
placement: 'top', placement: 'top',
html: true, html: true,
@@ -81,11 +79,11 @@ map.on('click', function (evt) {
// change mouse cursor when over marker // change mouse cursor when over marker
map.on('pointermove', function (e) { map.on('pointermove', function (e) {
if (e.dragging) {
$(element).popover('dispose');
return;
}
const pixel = map.getEventPixel(e.originalEvent); const pixel = map.getEventPixel(e.originalEvent);
const hit = map.hasFeatureAtPixel(pixel); const hit = map.hasFeatureAtPixel(pixel);
map.getTarget().style.cursor = hit ? 'pointer' : ''; map.getTarget().style.cursor = hit ? 'pointer' : '';
}); });
// Close the popup when the map is moved
map.on('movestart', function () {
$(element).popover('dispose');
});