[英]how to get a Popup by id in OpenLayers map
When initial the map, I created many popup for features 初始地图时,我为功能创建了许多弹出窗口
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);
but I can not get a exist popup when I location a point ,I want get it by it's id and show it, please help me 但是当我定位一个点时,我无法获得一个存在的弹出窗口,我想通过它的id来显示它并显示它,请帮助我
The idea should be: when the user click on a certain point recognized by you, the popup should be displayed, isn't it? 这个想法应该是:当用户单击您识别的某个点时,应该显示弹出窗口,不是吗?
You can do it in this way: 您可以通过以下方式进行操作:
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.