I need a popup to be opened when clicking on the features of a vector layer. I used the Vector Icon Example as starting point. My problem is that when a feature is covered by the popup, you can still click it (Fiddle-Demo: click the lower point and you can click the upper one through the popup). How can prevent this behavior?
Relevant code:
map.on('click', function(evt) {
var element = popup.getElement();
$(element).popover({
"placement": "top",
"html": true
});
var popover = $(element).data("bs.popover");
var feature = map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) {
return feature;
});
if (feature) {
popup.setPosition(feature.getGeometry().getCoordinates());
popover.options.content = feature.get("name");
$(element).popover('show');
} else {
$(element).popover('destroy');
}
});
Set
stopEvent: true
to yourol.Overlay
object, as such:See your updated Fiddle demo.