skyline画折现bug代码

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>加载3dwindow</title>

</head>
<body onload="init3d()">
<div style="margin:0">
<button type="button" onclick="start_line"> 开始</button>
<!-- <span id='pos'></span> -->

<div id="3dmap" style="z-index:0;background-image:url('images/bg.jpg');width:100%;height:100%;margin-top:38px;position:fixed;">
<object class="window3d" id="TerraExplorer3DWindow" classid="CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1"></object>
</div>
</div>
</body>
<script type="text/javascript">
function init3d() {
var dmap = $("3dmap");
var TerraExplorer3DWindow = $("TerraExplorer3DWindow");
dmap.appendChild(CSGWorld());

var SGWorld = $("SGWorld");
//
// SGWorld.AttachEvent("onLButtonDown", onLButtonDown);
// SGWorld.AttachEvent("onRButtonDown", onRButtonDown);

var flyurl = "../Default.FLY";
SGWorld.Open(flyurl);
}

function $(id) {
return window.document.getElementById(id);
}

function CSGWorld() {
obj = document.createElement('object');
document.body.appendChild(obj);
obj.name = "SGWorld";
obj.id = "SGWorld";
obj.classid = "CLSID:3A4F919A-65A8-11D5-85C1-0001023952C1";
return obj;
}
</script>
<script type="text/javascript">
function start_line() {
var SGWorld = $("SGWorld");
SGWorld.AttachEvent("onLButtonDown", onLButtonDown);
SGWorld.AttachEvent("onRButtonDown", onRButtonDown);
}


var line_geometry = []

function onRButtonDown(flags, x, y) {

SGWorld.DetachEvent("onLButtonDown", onLButtonDown);
SGWorld.DetachEvent("onRButtonDown", onRButtonDown);

}

function onLButtonDown(flags, x, y) {
var SGWorld = $("SGWorld");

var ret = SGWorld.Window.PixelToWorld(x, y, flags);
line_geometry.push(ret.Position.X, ret.Position.Y, 180)
if (line_geometry.length > 1) {
var geometry = SGWorld.Creator.GeometryCreator.CreateLineStringGeometry(line_geometry)
}

var color = SGWorld.Creator.CreateColor(255, 0, 0, 0.7);
// 2 in AltitudeTypeCode means on terrain, "" means add to root 
var line = SGWorld.Creator.CreatePolyline(geometry, color, 2, "", "my poly on terrain");
line.LineStyle.Width = 1.5; // 15000m (15km)
line.Position.Distance = 600.0; // set max viewing distance in meters
SGWorld.Navigate.FlyTo(line);

// 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.
}
</script>
<style type="text/css">
.window3d {
z-index: -1000;
width: 100%;
height: 100%;
position: absolute;
left: 0px;
top: 10px;
margin: 0;
}
</style>
</html>

猜你喜欢

转载自www.cnblogs.com/didib/p/9958460.html
今日推荐