我有一个使用 OpenLayers 2.13.1 的应用程序。它正在使用 bing 底图并覆盖 WMS 图层。我正在使用 FramedCloud 弹出窗口。我希望弹出窗口出现在用户单击的位置,有时会出现。有时,它会随机出现在用户点击位置的东侧或西侧。这是一段代码,显示了我的设置方式:
boxSize = new OpenLayers.Size(450, 120);
if (innovate.popupbox[mapID]) {
innovate.popupbox[mapID].lonlat = map.getLonLatFromPixel(event.xy);
innovate.popupbox[mapID].setContentHTML(content);
innovate.popupbox[mapID].setSize(boxSize);
//innovate.popupbox[mapID].panIntoView();
//innovate.popupbox[mapID].updatePosition();
innovate.popupbox[mapID].show();
} else {
//first popup load - we will create a popup object
//and for next time we will reuse this object rather than creating a new one
innovate.popupbox[mapID] = new OpenLayers.Popup.FramedCloud(
"innovate_info_popup_" + mapID,
map.getLonLatFromPixel(event.xy),
boxSize,
content,
null,
true
);
innovate.popupbox[mapID].panMapIfOutOfView = true;
innovate.popupbox[mapID].hide = function() {
this.div.style.display = 'none';
map.panTo(innovate.lastPopupCenter[mapID]);
}
map.addPopup(innovate.popupbox[mapID]);
}