我正在尝试使用openlayer的移动版本,不幸的是我无法在其中使用framedcloud,我只能创建一个方形弹出窗口,看起来不太美观,此外主要需要从相关数据点的云中识别,所以弹出方块没用,少用 jquery 或其他库..
我们使用 square 实现的方法是导入 popup popup openlayers 库,但该技巧不适用于 framedcloud(firebug 说“OpenLayers.Popup.FramedCloud 不是构造函数”)
<link rel="stylesheet" href="../scripts/OpenLayers-2.13.1/theme/default/style.mobile.css" type="text/css" >
....
<script type="text/javascript" language="javascript" src="../scripts/OpenLayers-2.13.1/OpenLayers.mobile.js"></script>
<script type="text/javascript" la language="javascript" src="../Scripts/OpenLayers-2.13.1/lib/OpenLayers/Popup.js"></script>
.....
function putPopup(x, y, html,map) {
// alert("popup1"+x+" "+y+" "+html)
map.setCenter(new OpenLayers.LonLat(x, y));
if (popup) {
map.removePopup(popup);
}
// this.popup = new OpenLayers.Popup("chicken",
// new OpenLayers.LonLat(x, y), null, html, null, true);
//-------------------------Fail-------------------------------------
//popup = new OpenLayers.Popup("chicken",
// new OpenLayers.LonLat(x, y),
// new OpenLayers.Size(120,50),
// html,
// true);
//-------------------------Fail-------------------------------------
popup = new OpenLayers.Popup.FramedCloud("Popup",
new OpenLayers.LonLat(x, y), null,
html, null,
true // <-- true if we want a close (X) button, false otherwise
);
//-------------------------Fail-------------------------------------
//var myPopupClass = new OpenLayers.Class
// (
// OpenLayers.Popup.FramedCloud,
// {
// 'autoSize': true,
// 'maxSize': new OpenLayers.Size(500,500)
// }
// );
//
// var myPopup = new myPopupClass
// (
// "chicken",
// new OpenLayers.LonLat(x, y),
// null,
// html,
// null,
// true
// );
// map.addPopup(myPopup);
map.addPopup(popup);
};