[英]How to make a clicked link center and show a popup on the map using OpenLayers?
[英]how to get a Popup by id in OpenLayers map
初始地圖時,我為功能創建了許多彈出窗口
var popup= new OpenLayers.Popup.FramedCloud(
id, //id
new OpenLayers.LonLat(msg.reviseLng, msg.reviseLat),
new OpenLayers.Size(160,100),
'<html></html>',
null,
true);
popup.autoSize=false;
map.addPopup(popup);
但是當我定位一個點時,我無法獲得一個存在的彈出窗口,我想通過它的id來顯示它並顯示它,請幫助我
這個想法應該是:當用戶單擊您識別的某個點時,應該顯示彈出窗口,不是嗎?
您可以通過以下方式進行操作:
map.events.register("click", map , function(e){
// Look for point... (your code)
// Point detected!
// now we need to take the popup identified by 'popupid' identifier and show it
for(var i=0; i<map.popups.length; i++){
if(map.popups[i].id == myid){
map.popups[i].show();
break;
}
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.