如何防止功能部件通过弹出窗口单击? [英] How to prevent feature clicks through popup?
本文介绍了如何防止功能部件通过弹出窗口单击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
单击矢量层的要素时,需要打开一个弹出窗口.我以矢量图标示例为起点.我的问题是,当弹出菜单包含某个功能时,您仍然可以单击它( Fiddle-Demo :单击较低的位置,则可以通过弹出窗口单击上方的位置).如何防止这种行为?
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?
相关代码:
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');
}
});
推荐答案
将stopEvent: true
设置为ol.Overlay
对象,例如:
var popup = new ol.Overlay({
element: element,
positioning: 'bottom-center',
stopEvent: true
});
请参阅您的更新的Fiddle演示.
这篇关于如何防止功能部件通过弹出窗口单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文