skyline二次开发 Popup浅谈

在skylines上弹出html页面用ShowPopup的接口:
在创建popup之前要创建CreatePopupMessage:
var url=abspath() + "/model_pop.html"+ "?obj_model="+id;
SGWorld.Creator.CreatePopupMessage("3D模型信息",url ,1707,0,450,420,-1);
SGWorld.Window.ShowPopup(pop);
abspath(),当前界面的绝对路径,利用key,value的形式把参数传到Popup中。

在Popup中var url = document.location.href;
var value = url.split("=");
var x = value[1];
来接受传过来的参数
Pop接受多个参数
window.onload = function(){
b();
var buildingname = "";
var lh = "";
var floor = "";
var winurl = decodeURI(window.location.href);
var wlp = winurl.split("?")[1];
var wincs = wlp.split("&");
if(wincs != null && wincs.length > 0){
for (var i = 0; i < wincs.length; i++) {
var tur = wincs[i].split("=");
if (tur[0] == "floor") {
floor = tur[1];
}else if(tur[0] == "buildingname"){
buildingname = tur[1];
}else if(tur[0] == "lh"){
lh = tur[1];
}
}
}
}

这样Popup就创建完成了,接下来是要删除Popup:
删除Popup有三种方法
1.自带的方法
缺点:灰色条样式不好看。
2.根据Popup对象来删除
SGWorld.Window.RemovePopup(Popup);
跟自带的方法一样
3.根据Popup的名称来删除
SGWorld.Window.RemovePopupByCaption("3D模型信息");
pop.ShowCaption=false;
缺点:Popup页面无法移动。

解决Popup接受OpenLayers发布的sfs服务数据
var b = function a() {
var _class = OpenLayers.Format.XML;
var originalWriteFunction = _class.prototype.write;
var patchedWriteFunction = function() {
var child = originalWriteFunction.apply(this, arguments);
// NOTE: Remove the rogue namespaces as one block of text.
// The second fragment "NS1:" is too small on its own and could cause valid text (in, say, ogc:Literal elements) to be erroneously removed.
child = child.replace(new RegExp('xmlns:NS1="" NS1:', 'g'), '');
return child;
}
_class.prototype.write = patchedWriteFunction
};

你可能感兴趣的:(skyline二次开发 Popup浅谈)