具有多点功能的弹出窗口 [英] popup with multiple points features
问题描述
我在打开第5层时遇到了一些麻烦 寻找/应对这个例子 https://openlayers.org/en/latest/examples/icon. html?q = marker
i'm having some troubles with open layer 5 looking/coping this example https://openlayers.org/en/latest/examples/icon.html?q=marker
具有多个可点击图标" 如果我单击并打开弹出窗口, 然后,如果我单击地图(而不是图标),弹出窗口消失了,好吧! 但是如果我在第一个图标上打开了一个弹出框,然后单击另一个图标,气球将在下一个图标上移,但是内容不会更改...
having more than one "clickable icon" if i click and open the popup is ok, then if i click the map (not icons) the popup goes away, well! but if i've a popover opened on the first icon, and then i click another one icon, the ballon move up the next, but the content is not changed...
我错了!!谢谢
推荐答案
在创建新弹出窗口之前,您需要销毁旧弹出窗口.但是销毁后立即重新创建可能存在问题,请参见 Bootstrap popover销毁&重新创建仅每隔第二次起作用,因此您可能需要短暂的超时,并且示例中相关代码的更新看起来像
You need to destroy the old popup before creating a new one. But there may be a problem with destroy followed immediately by recreate, see Bootstrap popover destroy & recreate works only every second time so you may need a short timeout and the update to the relevant code in the example would look like
if (feature) {
$(element).popover('destroy');
setTimeout(function () {
var coordinates = feature.getGeometry().getCoordinates();
popup.setPosition(coordinates);
$(element).popover({
'placement': 'top',
'html': true,
'content': feature.get('name')
});
$(element).popover('show');
}, 200);
} else {
$(element).popover('destroy');
}
或者您可以尝试基于该问题中其他答案之一的解决方案
or you could try a solution based one of the other answers in that question
这篇关于具有多点功能的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!