Skyline软件二次开发初级——5如何在WEB页面中的三维地图上使用事件函数
2012-09-22 11:01
549 查看
1.onFrame事件 - 移动摄像机:
<html>
<head>
<title>onFrame - Move camera</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var time = 5 * 1000; // move for 5 sec.
function Init()
{
SGWorld.AttachEvent("onFrame", onFrame);
SGWorld.Navigate.JumpTo(SGWorld.Creator.CreatePosition(-100.0, 40.0, 13000000, 3, 0, -85));
setTimeout(function () { SGWorld.DetachEvent("onFrame", onFrame); }, time);
}
function onFrame()
{
var pos = SGWorld.Navigate.GetPosition();
pos.X += 0.5;
pos.Y -= 0.2;
SGWorld.Navigate.SetPosition(pos);
}
</script>
</head>
<body onload="Init();">
</body>
</html>
2.onFrame事件 - 移动对象:
<html>
<head>
<title>onFrame - Move objects</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script src="abspath.js" type="text/javascript"></script>
<script type="text/javascript">
var model = null;
var time;
function Init()
{
time = new Date();
SGWorld.AttachEvent("onFrame", onFrame);
var pos = SGWorld.Creator.CreatePosition(-122.38050, // x
37.62331, // y
40.0, // height
3, // height type
297.0, // yaw
15.0, // pitch
0, // roll
0 // dist
);
model = SGWorld.Creator.CreateModel(pos, toAbspath("data/747.xpc"), 0.2);
model.Attachment.AutoDetach = false;
SGWorld.Navigate.FlyTo(model);
}
function onFrame(elapsedTime)
{
// move object with speed of 400km/h
var distToMove = (400 * 1000 / 3600) * (new Date().getTime() - time.getTime()) / 1000;
model.Position = model.Position.Move(distToMove, model.Position.Yaw + 0.1, model.Position.Pitch);
time = new Date();
}
</script>
</head>
<body onload="Init();">
</body>
</html>
3.onLButtonDown事件:
<html>
<head>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var globe = null;
var pos = null;
var popup, popup2;
function Init()
{
SGWorld.AttachEvent("onLButtonDown", onLButtonDown);
SGWorld.AttachEvent("onRButtonDown", onRButtonDown);
popup2 = SGWorld.Creator.CreatePopupMessage()
popup2.InnerText = "Left click on the terrain to get the coordinates at cursor position. Right click to finish.";
SGWorld.Window.ShowPopup(popup2);
}
function onLButtonDown(flags, x,y)
{
var ret = SGWorld.Window.PixelToWorld(x, y);
popup = SGWorld.Creator.CreatePopupMessage("onLButtonDown event", "", x, y);
popup.InnerText = (ret == null) ? "Screen coordinate hit the sky" : "Screen coordinates ("+x+","+y+"):\nTerrain coordinate:\nX: " + ret.Position.X + "\nY: " + ret.Position.Y;
SGWorld.Window.ShowPopup(popup);
return true; // event was processed by the client. return false to allow additional processing of the event.
}
function onRButtonDown(flags, x,y)
{
SGWorld.DetachEvent("onLButtonDown", onLButtonDown);
SGWorld.DetachEvent("onRButtonDown", onRButtonDown);
if(popup)
SGWorld.Window.RemovePopup(popup);
if(popup2)
SGWorld.Window.RemovePopup(popup2);
return true; // event was processed by the client. return false to allow additional processing of the event.
}
</script>
</head>
<body onload="Init();">
</body>
</html>
4.屏蔽右键弹出菜单:
<html>
<head>
<title>Preventing right popup</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
function Init()
{
SGWorld.AttachEvent("onRButtonDown", onRButtonDown);
SGWorld.AttachEvent("onRButtonDblClk", onRButtonDblClk);
SGWorld.Window.ShowMessageBarText("This sample shows how to disable the default right context menu. Double right-click to re-enable", 3);
}
function onRButtonDown(flags, x,y)
{
return true; // Tell TE that the OnRButtonDown event was processed by the client
}
function onRButtonDblClk(flags, x,y)
{
SGWorld.DetachEvent("onRButtonDown", onRButtonDown);
SGWorld.DetachEvent("onRButtonDblClk", onRButtonDblClk);
SGWorld.Window.HideMessageBarText();
alert("Right click is now enabled");
return false;
}
</script>
</head>
<body onload="Init();">
</body>
</html>
5.onTerraExplorerMessage事件:
<html>
<head>
<title>onTerraExplorerMessage event</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
function Init()
{
SGWorld.AttachEvent("onTerraExplorerMessage", onTerraExplorerMessage);
var label = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.00425, 42.36081, 100),
"Click here to get the name of the airport",SGWorld.Creator.CreateLabelStyle());
var msg = SGWorld.Creator.CreateMessage(0, "Logan International",0);
label.Message.MessageID = msg.ID;
SGWorld.Navigate.JumpTo(label);
}
function onTerraExplorerMessage(messageId, senderNodeId)
{
var message = SGWorld.Creator.GetObject(messageId);
var senderNode = SGWorld.Creator.GetObject(senderNodeId);
senderNode.Text = message.Text;
}
</script>
</head>
<body onload="Init();">
</body>
</html>
<html>
<head>
<title>onFrame - Move camera</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var time = 5 * 1000; // move for 5 sec.
function Init()
{
SGWorld.AttachEvent("onFrame", onFrame);
SGWorld.Navigate.JumpTo(SGWorld.Creator.CreatePosition(-100.0, 40.0, 13000000, 3, 0, -85));
setTimeout(function () { SGWorld.DetachEvent("onFrame", onFrame); }, time);
}
function onFrame()
{
var pos = SGWorld.Navigate.GetPosition();
pos.X += 0.5;
pos.Y -= 0.2;
SGWorld.Navigate.SetPosition(pos);
}
</script>
</head>
<body onload="Init();">
</body>
</html>
2.onFrame事件 - 移动对象:
<html>
<head>
<title>onFrame - Move objects</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script src="abspath.js" type="text/javascript"></script>
<script type="text/javascript">
var model = null;
var time;
function Init()
{
time = new Date();
SGWorld.AttachEvent("onFrame", onFrame);
var pos = SGWorld.Creator.CreatePosition(-122.38050, // x
37.62331, // y
40.0, // height
3, // height type
297.0, // yaw
15.0, // pitch
0, // roll
0 // dist
);
model = SGWorld.Creator.CreateModel(pos, toAbspath("data/747.xpc"), 0.2);
model.Attachment.AutoDetach = false;
SGWorld.Navigate.FlyTo(model);
}
function onFrame(elapsedTime)
{
// move object with speed of 400km/h
var distToMove = (400 * 1000 / 3600) * (new Date().getTime() - time.getTime()) / 1000;
model.Position = model.Position.Move(distToMove, model.Position.Yaw + 0.1, model.Position.Pitch);
time = new Date();
}
</script>
</head>
<body onload="Init();">
</body>
</html>
3.onLButtonDown事件:
<html>
<head>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var globe = null;
var pos = null;
var popup, popup2;
function Init()
{
SGWorld.AttachEvent("onLButtonDown", onLButtonDown);
SGWorld.AttachEvent("onRButtonDown", onRButtonDown);
popup2 = SGWorld.Creator.CreatePopupMessage()
popup2.InnerText = "Left click on the terrain to get the coordinates at cursor position. Right click to finish.";
SGWorld.Window.ShowPopup(popup2);
}
function onLButtonDown(flags, x,y)
{
var ret = SGWorld.Window.PixelToWorld(x, y);
popup = SGWorld.Creator.CreatePopupMessage("onLButtonDown event", "", x, y);
popup.InnerText = (ret == null) ? "Screen coordinate hit the sky" : "Screen coordinates ("+x+","+y+"):\nTerrain coordinate:\nX: " + ret.Position.X + "\nY: " + ret.Position.Y;
SGWorld.Window.ShowPopup(popup);
return true; // event was processed by the client. return false to allow additional processing of the event.
}
function onRButtonDown(flags, x,y)
{
SGWorld.DetachEvent("onLButtonDown", onLButtonDown);
SGWorld.DetachEvent("onRButtonDown", onRButtonDown);
if(popup)
SGWorld.Window.RemovePopup(popup);
if(popup2)
SGWorld.Window.RemovePopup(popup2);
return true; // event was processed by the client. return false to allow additional processing of the event.
}
</script>
</head>
<body onload="Init();">
</body>
</html>
4.屏蔽右键弹出菜单:
<html>
<head>
<title>Preventing right popup</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
function Init()
{
SGWorld.AttachEvent("onRButtonDown", onRButtonDown);
SGWorld.AttachEvent("onRButtonDblClk", onRButtonDblClk);
SGWorld.Window.ShowMessageBarText("This sample shows how to disable the default right context menu. Double right-click to re-enable", 3);
}
function onRButtonDown(flags, x,y)
{
return true; // Tell TE that the OnRButtonDown event was processed by the client
}
function onRButtonDblClk(flags, x,y)
{
SGWorld.DetachEvent("onRButtonDown", onRButtonDown);
SGWorld.DetachEvent("onRButtonDblClk", onRButtonDblClk);
SGWorld.Window.HideMessageBarText();
alert("Right click is now enabled");
return false;
}
</script>
</head>
<body onload="Init();">
</body>
</html>
5.onTerraExplorerMessage事件:
<html>
<head>
<title>onTerraExplorerMessage event</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
function Init()
{
SGWorld.AttachEvent("onTerraExplorerMessage", onTerraExplorerMessage);
var label = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(-71.00425, 42.36081, 100),
"Click here to get the name of the airport",SGWorld.Creator.CreateLabelStyle());
var msg = SGWorld.Creator.CreateMessage(0, "Logan International",0);
label.Message.MessageID = msg.ID;
SGWorld.Navigate.JumpTo(label);
}
function onTerraExplorerMessage(messageId, senderNodeId)
{
var message = SGWorld.Creator.GetObject(messageId);
var senderNode = SGWorld.Creator.GetObject(senderNodeId);
senderNode.Text = message.Text;
}
</script>
</head>
<body onload="Init();">
</body>
</html>
相关文章推荐
- Skyline软件二次开发初级——4如何在WEB页面中的三维地图上使用弹出框Popups
- Skyline软件二次开发初级——6如何在WEB页面中的三维地图上进行坐标和方向计算
- Skyline软件二次开发初级——9如何在WEB页面中的三维地图上进行交互
- Skyline软件二次开发初级——3如何在WEB页面中的三维地图上创建几何对象
- Skyline软件二次开发初级——10如何在WEB页面中的三维地图上控制图层对象
- Skyline软件二次开发初级——1如何在web页面中添加控件和加载三维地图数据
- Skyline软件二次开发初级——2如何在WEB页面中控制三维地图的观察点坐标和角度
- Skyline软件二次开发初级——11如何在WEB页面中的三维地图上加载和保存工程文件
- Skyline软件二次开发初级——7如何在WEB页面中的三维地图上设置颜色
- Skyline软件二次开发初级——8如何在WEB页面中的三维地图上管理信息树
- 如何使用报表制作工具软件进行二次开发
- java web开发中,jsp使用了frameset框架,如何实现整个页面跳转,并且同一个表单中可以提交两个action
- Android 软件开发之如何使用Eclipse Debug调试程序详解
- Android 软件开发之如何使用Eclipse Debug调试程序详解
- 使用Python如何访问svn做二次开发
- 使用Sencha Designer来快速开发web用户界面 -- 页面布局
- Skyline Web 二次开发- 场景应用(模型点位标注与获取某个点位模型高程值)
- 学习使用J2EE Web应用的事件功能-Java基础-Java-编程开发
- 使用webview加载本地html页面,并处理html页面中的javascript事件
- 如何在单击WEB控件引发页面刷新时定位页面?(不使用智能导航)