版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。 https://blog.csdn.net/bitree1/article/details/79241376
1.web工程調用網絡fly檔案
(1)建立一個空的web工程,并在工程中建立一個HTML頁面,将頁面分成左右結構,并将skyline的相關對象引入到頁面中,如下圖所示:
備注:
上圖中的各OBJECT對象從“TerraExplorer Pro”軟體中的程式開發指南中複制。
步驟1:打開“TerraExplorer Pro”軟體,找到程式開發指南,如下圖:
步驟2:進入ActiveX controls,将以下的Object資訊分别複制到html頁面中。
備注:在拷貝API資訊後,記得将多餘的空格去掉,不然會頁面将無法識别該API。
(2)浏覽web工程頁面,便可打開頁面,也可以将該建立的web工程部署到iis中,随時通路
(3)在html頁面上直接寫<object></object>會出現一個問題,html加載skyline的時候有時候三維的模型不在html頁面上顯示反而調用了本地的terraexplorer pro軟體
這個原因是初始化先後的問題,為了解決這個問題我們 可以在js裡面動态加載sgword等等。代碼片段如下
createSGWorld:function(){
var self = this;
var dom = this.TEBox;
//<!--定義一個TerraExplorer 3D視窗對象-->
var sgword = domConstruct.create("object", {
id:"TE3DWindow",
classid: "CLSID:3A4F9197-65A8-11D5-85C1-0001023952C1"
});
domStyle.set(sgword,"width:100%;height:100%;");
//<!--定義一個TerraExplorer 對象-->
var TE = domConstruct.create("object", {
id:"TerraExplorerX",
classid: "CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1"
});
domStyle.set(TE,"width","100%");
domStyle.set(TE,"height","100%");
dom.appendChild(TE);
//定義TerraExplorer的資訊視窗對象
self.TEinfowindow = domConstruct.create("object", {
id:"TerraExplorerInformationWindow",
classid: "CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1"
});
domStyle.set(self.TEinfowindow,"position","absolute");
domStyle.set(self.TEinfowindow,"bottom","5px");
domStyle.set(self.TEinfowindow,"right","10px");
domStyle.set(self.TEinfowindow,"width","250px");
domStyle.set(self.TEinfowindow,"height","300px");
dom.appendChild(self.TEinfowindow);
//<!--定義TerraExplorer對象SGWorld65-->
var SGWorld = domConstruct.create("object", {
id:"SGWorld66",
name:"SGWorld66",
//classid:"CLSID:3A4F9197-65A8-11D5-85C1-0001023952C1"//6.5版本
classid:"CLSID:3A4F9199-65A8-11D5-85C1-0001023952C1"
});
dom.appendChild(SGWorld);
return SGWorld;
}
(4)判斷是否安裝了terraexplorer代碼片段
initSGWorld: function(extent,isCompare) {
var self = this;
this.SGWorld = this.createSGWorld();
var InformationWindow = self.TEinfowindow;
try {
if(!self.DisActiveX("TerraExplorerX.TE3DWindow.1")){
console.log(this.SGWorld.version);
alert("請先下載下傳并安裝TEPro6.6.1-SC插件!!!");
window.location=require.toUrl("./TEPro6.6.1-SC.zip");
}else{
this.SGWorld.Open(this.flyUrl);
}
} catch (e) {
return;
}
this.SGWorld.SetOptionParam("AltitudeType",1);
this.SGWorld.AttachEvent("OnLoadFinished", function() {
treeDtoolBar.SGWorld=self.SGWorld;
treeDtoolBar.InformationWindow=InformationWindow;
});
}
/**
* 檢測是否已安裝指定插件
*
* pluginName 插件名稱
*/
DisActiveX:function(pluginName)
{
var result;
try {
result = new ActiveXObject(pluginName);
delete result;
} catch (e) {
return false;
}
return true;
}
将不定期更新資源,歡迎持續關注
想獲得更多的學習知識請關注微信公衆号:西北碼農或掃下方二維碼