来自:http://archive.cnblogs.com/a/1553670/
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>lianxi</title>
</head>
<body OnLoad="Init();">
<object id="TEInformationWindow" classid="CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1" width="300" height="400">
<embed width="300" height="400"></embed>
</object>
<object ID="TE3DWindow" classid="CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1" width=650 height="400"></object>
<object ID="TE" CLASSId="CLSID:3a4f9191-65a8-11d5-85c1-0001023952c1"></object>
<hr/>
<br>
<table width="100%" height="133" border="1" align="center" bordercolor="#00FF33">
<tr>
<td width="16%" height="29" align="center">
<input type="button" name="createline" value="创建线" onClick="Createpolyline()">
<input type="button" name="Container" value="弹新窗口" onClick="Container()">
</td>
<td width="16%" align="center">
<input type="button" name="ITerraExplorer" value="pro属性" onClick="ProInfo()">
<input type="button" name="ITerraExplorer" value="pro方法" onClick="MethedInfo()">
</td>
<td width="16%" align="center">
<input type="button" name="typeInfo" value="ITerrain属性测试" onClick="ITerrainProInfo()">
</td>
<td colspan="3" align="center">
<input type="button" name="typeInfo" value="IStartPosition的属性" onClick="IIStartPositionInfo()">
<input type="button" name="typeInfo" value="IRender的属性" onClick="IRenderProInfo()">
<input type="button" name="addprograme" value="添加工程文件" onClick="AddG()">
</td>
</tr>
<tr>
<td height="25" colspan="2"><label>创建路径操作:</label>
<input type="button" name="createdynamic" value="创建" onClick="CreateDynamic()">
<input type="button" name="dynamicPlay" value="播放" onClick="DynamicPlay()">
<input type="button" name="dynamicstop" value="停止" onClick="DynamicStop()">
<input type="button" name="dynamicP" value="暂停" onClick="DynamicP()"> </td>
<td colspan="2" align="center">
<input type="text" name="text" value="新建组" id="CG" width="120">
<input type="button" name="createGroup" value="建用户组" id="GN" onClick="CreateGroup1()" ></td>
<td width="15%" align="center">
<input type="button" name="kuaizhao" value="快照" onClick="Menu.Invoke(32783)">
<input type="button" name="kzsaveas" value="鼠标模式" onClick="GetMouseMode()">
</td>
<td width="20%">
<input type="checkbox" name="showlaler" checked id="chk1" onClick="LayerVis()"> <label>显示和隐藏层</label>
</td>
</tr>
<tr>
<td height="21" colspan="4">
名称:<input name="Name" id="flyName" type="text" value="克拉玛依" size="12" width="100">
经度:<input name="flyJD" id="flyJD" type="text" value="87" size="10" width="100">
纬度:<input name="flyWD" id="flyWD" type="text" value="43" size="10" width="100">
<input type="button" value="起 飞" name="FlyToSomeWhere" onClick="FlyToSomeWhere()">
</td>
<td><input type="button" name="deleteobj" value="删除选定的对象" id="delobj" onClick="DelObj()"></td>
<td align="center"><input type="button" name="infortree" id="iftv" value="信息树的遍历" onClick="InformationTreeVist()"></td>
</tr>
<tr>
<td height="19"><input type="button" name="createpolygon" value="创建棱锥"onClick="CreateP()"></td>
<td> </td>
<td> </td>
<td width="17%"> </td>
<td> </td>
<td><input type="button" name="loadsave" value="加载我的操作" onClick="LoadFromSaved()"></td>
</tr>
<tr>
<td height="25" colspan="3">经度:<span id="jd"></span>纬度:<span id="wd"></span></td>
<td colspan="3"> <input type="button" value="保存" name="save" onClick="SaveAs()">
<input type="file" value="E:\a.fly" name="saveas" id="adr" width="10">
<input type="button" value="fly另存为" name="save" onClick="SaveAsOther()">
<label></label>
</td>
</tr>
</table>
</body>
<script language="javascript">
var ITerraExplorer = null;
var IInformationTree = null;
var Polylineflag = false;
var Dynamicflag = false;
var IRender = null;
var IPolyline = "";
var isLine = false;
var isRoute = false;
var IObiectManager = null;
var IStartPosition = null;
var Route = "";
var IContainer = null;
var IPlane = null;
var ITerrain = null;
var IStartPosition = null;
var ITerrain = null;
var Menu = null;
var ISnapShot = null;
var ItemID = "";
var curItemID = "";
var groupID = "";
var createpolygoyflag = false;
var isPolygon = false;
var IPolygon = "";
function Init()
{
ITerraExplorer = TE.interface("ITerraExplorer5");
IInformationTree = TE.interface("IInformationTree5");
IRender = TE.interface("IRender5");
IObjectManager = TE.interface("IObjectManager5");
IStartPosition = TE.interface("IStartPosition");
IContainer = TE.interface("IContainer2");
IPlane = TE.interface("IPlane5");
ITerrain = TE.interface("ITerrain4");
IStartPosition = TE.interface("IStartPosition");
IRender = TE.interface("IRender5");
Menu = TE.interface("IMenu");
ISnapShot = TE.interface("ISnapShot2");
ITerraExplorer.load("c:\\a.fly");
window.setTimeout("test()",800);
}
function test()
{
IInformationTree.LoadFlyLayerEx("[TE Application Data]\\本人上次的操作记录.fly",0);
IInformationTree.LoadFlyLayerEx("[TE Application Data]\\本人上次创建的动态路径.fly",0);
}
function SaveAs()
{
ITerraExplorer.Save();
alert("保存成功");
}
function SaveAsOther()
{
var txt = document.getElementById("adr").value;
if(txt!="")
{
ITerraExplorer.SaveAs(txt);
alert("保存成功");
}
else
alert("请输入要存储的位置!");
}
function Createpolyline()
{
Polylineflag = true;
IRender.SetMouseInputMode(1);
}
function CreateDynamic()
{
Dynamicflag = true;
IRender.SetMouseInputMode(1);
}
function TE::OnLButtonDown(flag,X,Y,Handled)
{
if(Polylineflag)
CreatePolylineVB(X,Y);
if(Dynamicflag)
CreateDynamicVB(X,Y);
if(createpolygoyflag)
CreatePolygonVB(X,Y)
}
function TE::OnRButtonDown(flag,X,Y,Handled)
{
Polylineflag = false;
Dynamicflag = false;
isLine = false;
isRoute = false;
IRender.SetMouseInputMode(0);
curItemID = "";
createpolygoyflag = false;
}
function Container()
{
//欢迎使用本产品!!的地方也可使用 URL定位
IContainer.HTMLPopup (0, 50,50,350,350,"容器窗口", "欢迎使用本产品!!" ,2, -1 );
}
function ProInfo()
{
alert(ITerraExplorer.TYPE);
alert(ITerraExplorer.FlyName);
alert(ITerraExplorer.DisplayErrorMessages = 1);
}
function MethedInfo()
{
alert(ITerraExplorer.GetUserUnits(0,3,5,7));
alert(ITerraExplorer.GetTEVersion("5","00","38"));
}
function ITerrainProInfo()
{
alert("mpt的文件名:"+ITerrain.MPTName);
alert("SystemKey的文件名:"+ITerrain.SystemKey);
alert("GroupKey的文件名:"+ITerrain.GroupKey);
alert("DatumKey的文件名:"+ITerrain.DatumKey);
alert("UnitKey的文件名:"+ ITerrain.UnitKey);
alert("EPSG的文件名:"+ ITerrain.EPSG);
alert("Description的文件名:"+ ITerrain.Description);
}
function IIStartPositionInfo()
{
alert("开始坐标X"+IStartPosition.StartX);
alert("开始坐标Z"+IStartPosition.StartZ);
}
function IRenderProInfo()
{
alert(IRender.HudMode = 6);
}
function CreateGroup1()
{
var groupID = null;
var GroupName = document.getElementById("CG").value;
if(GroupName!="")
groupID = IInformationTree.CreateGroup(GroupName,0);
else
alert("请输入要创建组的名字!");
}
function TE::OnInfoTreeAction(ItemID,Action,ActionParam)
{
curItemID = ItemID;
}
function AddG()
{
IInformationTree.LoadFlyLayer("E:\\skyline\\Terra pro练习http://www.cnblogs.com/shaoge/admin/file://lianxi//124.fly");
alert("工程添加成功!");
}
function LayerVis()
{
if (document.getElementById("chk1").checked)
IInformationTree.SetGroupVisibility(IInformationTree.FindItem("0"),true);
else
IInformationTree.SetGroupVisibility(IInformationTree.FindItem("0"),false);
}
function FlyToSomeWhere()
{
var tName,tX0,tZ0
tName = document.getElementById("flyName").value;
tX0 = document.getElementById("flyJD").value;
tZ0 = document.getElementById("flyWD").value;
CreateLabelFlyTo(tName,tX0,tZ0);
}
function CreateLabelFlyTo(txt,x1,z1)
{
var LabelInfo = new Object();
LabelInfo.Text = txt;
LabelInfo.Scale = 1;
LabelInfo.bgColor = 0xff00;
IObjectManager.CreateLabel(LabelInfo,x1,z1,2000.0);
IPlane.FlyTo(x1,z1,2000.0,117.98,0,-35,"Oval");
}
function DelObj()
{
if(curItemID =="")
{
alert("请选定你要删除的对象!");
}
else
{
IInformationTree.DeleteItem(curItemID);
alert("删除成功!");
curItemID ="";
}
}
function InformationTreeVist()
{
var groupID = IInformationTree.GetNextItem(0, 11);
if (groupID == 0)
{
alert("信息树中无对象!");
return 0;
}
else
InformationTreeAll(groupID);
}
function InformationTreeAll(groupID)
{
var a,b,c;
if (groupID == 0)
return 0;
else
{
b = confirm(IInformationTree.GetItemName(groupID)+"__ID:"+groupID);
if(b == false)
{
return 0;
}
a = groupID;
groupID = IInformationTree.GetNextItem(groupID,11);
if(groupID == 0)
{
groupID = IInformationTree.GetNextItem(a,13);
if(groupID == 0)
{
groupID = IInformationTree.GetNextItem(a,15);
c = groupID;
groupID = IInformationTree.GetNextItem(c,13);groupID
while(groupID == 0 )
{
groupID = IInformationTree.GetNextItem(c,15);
groupID = IInformationTree.GetNextItem(groupID,13);
if (groupID == 0)
return 0;
}
}
}
InformationTreeAll(groupID);
}
}
function LoadFromSaved()
{
alert(IInformationTree.LoadFlyLayerEx("[TE Application Data]\\e.fly",0));
}
/*function CreateP()
{
createpflag = true;
IObjectManage.CreatePyramid(x,y,);
}*/
</script>
<script language="vbscript">
function CreatePolylineVB(x,y)
dim outX,outY,outH,ObjectID
IRender.ScreenToWorld x,y,63,outX,outH,outY,ObjectID
if curItemID<>"" then
if IInformationTree.IsGroup(curItemID) then
if isLine = false then
isLine = true
Set IPolyline = IObjectManager.CreatePolyline(0,16744555,2,curItemID,"创建线")
else
IPolyline.AddVertex outX,outH,outY,0
end if
IInformationTree.SaveFlyLayer "本人上次的操作记录.fly",curItemID
else
msgbox "你选择的是对象不能容纳对象,请选择组!"
end if
else
msgbox "请选择容纳对象的组!"
end if
end function
function CreateDynamicVB(x,y)
IRender.ScreenToWorld X,Y,63,outX,outH,outY,ObjectID
if curItemID<>"" then
if IInformationTree.IsGroup(curItemID) then
if isRoute = false then
set Route = IObjectManager.CreateRoute (empty,0,curItemID,"动态路径")
isRoute = true
else
Route.AddWaypoint outX,outH,outY,0,-45,0,-45,0,100,""
end if
IInformationTree.SaveFlyLayer "本人上次创建的动态路径.fly",curItemID
else
msgbox "你选择的是对象不能容纳对象,请选择组!"
end if
else
msgbox "请选择容纳对象的组!"
end if
end function
function DynamicPlay()
Route.Play
msgbox "播放动态路径"
end function
function DynamicP()
Route.Pause
msgbox "暂停播放动态路径"
end function
function GetMouseMode()
msgbox IRender.GetMouseInputMode
end function
function TE_OnFrame()
dim x1,y1
IRender.GetMouseInfo 1,x1,y1
ObjType = 0
IRender.ScreenToWorld x1,y1,ObjType,WorldX,WorldHeigth,WorldY,ObjectID
document.getElementById("jd").innerHTML = WorldX
document.getElementById("wd").innerHTML = WorldY
end function
</script>
</html>