Skyline软件二次开发初级——3如何在WEB页面中的三维地图上创建几何对象
1.在地面上繪制一條折線:
<html>?<head>
????????<title>Create?Polyline</title>
????????<object?id="SGWorld"?classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1"?style="visibility:hidden;height:0?"></object>
????????<script?type="text/javascript">
????????function?Init()
????????{
????????????//?geometry?creator?can?work?on?WKT,?WKB?or?array?of?x,z,y?coordinates
????????????var?geometry?=?SGWorld.Creator.GeometryCreator.CreateLineStringGeometry([-114.73656,?36.01659,0,?-115.14515,?36.15498,0,?-118.24834,?34.05090,0]);
????????????var?color?=?SGWorld.Creator.CreateColor(255,?0,?0,?0.7);
????????????//?2?in?AltitudeTypeCode?means?on?terrain,?0?means?add?to?root?
????????????var?line?=?SGWorld.Creator.CreatePolyline(geometry,?color,?2,?0,?"my?poly?on?terrain");
????????????line.LineStyle.Width?=?15000;?//?15000m?(15km)
????????????line.Position.Distance?=?600000.0;?//?set?max?viewing?distance?in?meters
????????????SGWorld.Navigate.FlyTo(line);????????????
????????}
????????
????????</script>
????</head>
????<body?onload="Init();">
????</body>
</html>
2. 在空中繪制一條折線:
<html>?<head>
????????<title>Create?Polyline</title>
????????<object?id="SGWorld"?classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1"?style="visibility:hidden;height:0?"></object>
????????<script?type="text/javascript">
????????function?Init()
????????{
????????????var?geometry?=?SGWorld.Creator.GeometryCreator.CreateLineStringGeometry([-114.73656,?36.01659,?10000,?-115.14515,?36.15498,?300000,?-118.24834,?34.05090,?700000]);
????????????//?3?in?AltitudeTypeCode?means?absolute,?0?means?add?to?root?
????????????var?line?=?SGWorld.Creator.CreatePolyline(geometry,?"#ff0000",?3,?0,?"my?poly");
????????????line.Position.Distance?=?900000.0;?//?set?max?viewing?distance?in?meters
????????????SGWorld.Navigate.FlyTo(line);
????????}
????????
????????</script>
????</head>
????<body?onload="Init();">
????</body>
</html>
3.繪制多邊形:
<html>?????<head>
????????<title>Create?Polygons</title>
????????<object?id="SGWorld"?classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1"?style="visibility:hidden;height:0?"></object>
????????<script?type="text/javascript">
????????
????????function?Init()
????????{
????????????var?pointsUtah?=?SGWorld.Creator.GeometryCreator.CreateGeometryFromWKT("POLYGON((-114.03822?41.99547,-111.04795?41.99626,-111.05028?40.99663,-109.04763?40.99847,-109.04782?36.99664,-114.04313?36.99656,-114.03822?41.99547))");
????????????//?2?in?AltitudeTypeCode?means?on?terrain,?0?means?add?to?root?
????????????var?polyUtah?=?SGWorld.Creator.CreatePolygon(pointsUtah,?"#ff0000",?SGWorld.Creator.CreateColor(0,?255,?255,?40),?2,?0,?"Utah");?//
????????????polyUtah.LineStyle.Width?=?5000;?//?5000m?(5km)
????????????var?pointsWyoming?=?SGWorld.Creator.GeometryCreator.CreateGeometryFromWKT("POLYGON((-111.05265?44.99576,-104.05934?44.99734,-104.05120?41.00322,-111.05028?40.99663,-111.05265?44.99576))");
????????????//?2?in?AltitudeTypeCode?means?on?terrain,?0?means?add?to?root?
????????????var?polyWyoming?=?SGWorld.Creator.CreatePolygon(pointsWyoming,?SGWorld.Creator.CreateColor(255,?255,?0,?10),?null,2,0,?"Wyoming");
????????????polyWyoming.LineStyle.Width?=?20000;?//?20000m?(20km)
????????????polyWyoming.Position.Distance?=?1600000;
????????????SGWorld.Navigate.FlyTo(polyWyoming);
????????}
????????
????????</script>
????</head>
????<body?onload="Init();">
????</body>
</html>
4.繪制圓形:
<html>?<head>
????????<title>Create?Circle</title>
????????<object?id="SGWorld"?classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1"?style="visibility:hidden;height:0?"></object>
????????<script?type="text/javascript">
????????
????????function?Init()
????????{
????????????var?circle?=?SGWorld.Creator.CreateCircle(SGWorld.Creator.CreatePosition(-71.00864,?42.36229,0,2),??//?Pivot
????????????????????????????????????????????????????1000.0,?????????????????????????????????????????????????????//?Radius?(1000m)
????????????????????????????????????????????????????SGWorld.Creator.CreateColor(0,?0,?0,?0),????????????????????//?Outline?color?(in?this?sample,?transparent/no?outline)
????????????????????????????????????????????????????SGWorld.Creator.CreateColor(200,?50,?50,?128)???????????????//?Fill?color
????????????????????????????????????????????????????);
????????????circle.Position.Distance?=?3000;
????????????SGWorld.Navigate.FlyTo(circle);?
????????}
????????
????????</script>
????</head>
????<body?onload="Init();">
????</body>
</html>
5.創(chuàng)建文本標(biāo)簽:
<html>?<head>
????????<title>Create?Basic?Labels</title>
????????<object?id="SGWorld"?classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1"?style="visibility:hidden;height:0?"></object>
????????<script?type="text/javascript">
????????????????
????????function?Init()
????????{
????????????var?labelPos?=?SGWorld.Creator.CreatePosition(-122.41519,?37.74346,?100,?2);
????????????//?Default?label
????????????var?label1?=?SGWorld.Creator.CreateTextLabel(labelPos,?"Default?label",SGWorld.Creator.CreateLabelStyle());
????????????var?labelStyle?=?SGWorld.Creator.CreateLabelStyle();
????????????labelStyle.Bold?=?true;
????????????labelStyle.LineToGround?=?true;
????????????labelStyle.TextColor?=?SGWorld.Creator.CreateColor(255,?0,?0);
????????????//?Label?2
????????????labelPos.X?+=?0.001;
????????????var?label2?=?SGWorld.Creator.CreateTextLabel(labelPos,?"Bold?Red?label\r\nwith?line?to?ground",?labelStyle);
????????????
????????????//?Labe?3?
????????????labelStyle.BackgroundColor?=?SGWorld.Creator.CreateColor(255,?255,?255);
????????????labelStyle.Italic???????????=?true;
????????????labelStyle.LineToGround?????=?false;
????????????
????????????labelPos.x?+=?0.001;????????????
????????????var?label3?=?SGWorld.Creator.CreateTextLabel(labelPos,?"Red?bold?italic?label\r\nwith?white?background",?labelStyle);
????????????//?Labe?4?
????????????labelStyle.BackgroundColor?=?SGWorld.Creator.CreateColor(255,?255,?255,?0.5);
????????????labelStyle.Underline???????=?true;
????????????
????????????labelPos.y?+=?0.001;????????????
????????????var?label4?=?SGWorld.Creator.CreateTextLabel(labelPos,?"Underlined?italic?with\r\nsemi?transparent?background",?labelStyle);
????????????//?Labe?5?
????????????labelStyle.FontSize?=?24;
????????????labelStyle.FontName?=?"Times?New?Roman";
????????????
????????????labelStyle.Bold??????=?false;
????????????labelStyle.Italic????=?false;
????????????labelStyle.Underline?=?false;
????????????labelPos.x?-=?0.002;????????????
????????????var?label5?=?SGWorld.Creator.CreateTextLabel(labelPos,?"Font:Times?New?Roman\r\nSize:24px",?labelStyle);
????????????SGWorld.Navigate.FlyTo(label1);
????????}
????????
????????</script>
????</head>
????<body?onload="Init();">
????</body>
</html>
6.創(chuàng)建帶圖片的文本標(biāo)簽:
<html>?<head>
????????<title>Create?Image?Labels</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">
????????????????
????????function?Init()
????????{
????????????var?labelPos?=?SGWorld.Creator.CreatePosition(-122.46875,?37.72467,?10,?2);
????????????var?label1?=?SGWorld.Creator.CreateLabel(labelPos,?"",?toAbspath("data/Roundabout-large.gif"),SGWorld.Creator.CreateLabelStyle());
????????????SGWorld.Navigate.FlyTo(label1);
????????????labelPos.X?+=?0.001;
????????????labelPos.Altitude?+=?60;
????????????var?label2?=?SGWorld.Creator.CreateLabel(labelPos,?
???????????????????????????????????????????????????"Under?Constructions.\r\nThis?label?will?not?be?visible\r\nabove?~800000?meters",
???????????????????????????????????????????????????toAbspath("data/Underconstruction-2.gif"),SGWorld.Creator.CreateLabelStyle()
???????????????????????????????????????????????????);
????????????label2.Style.TextOnImage?=?false;
????????????label2.Style.Bold?=?true;
????????????label2.Style.LineToGround?=?true;
????????????label2.Style.MultilineJustification?=?"left";
????????????label2.Style.TextAlignment?=?"right";
????????????label2.Visibility.MaxVisibilityDistance?=?800000;
????????}
????????</script>
????</head>
????<body?onload="Init();">
????</body>
</html>
7.創(chuàng)建三維模型:
<html>?<head>
????????<title>Create?Model</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">
????????????????
????????function?Init()
????????{
????????????var?pos?=?SGWorld.Creator.CreatePosition(-122.38050,?//?x
??????????????????????????????????????????????????????37.62331,??//?y
??????????????????????????????????????????????????????40.0,??????//?height
??????????????????????????????????????????????????????3,?????????//?absolute
??????????????????????????????????????????????????????297.0,?????//?yaw
??????????????????????????????????????????????????????15.0);?????//?pitch
????????????var?model?=?SGWorld.Creator.CreateModel(pos,?toAbspath("data/747.xpc"),?0.2);
????????????SGWorld.Navigate.FlyTo(model);
????????????
????????}
????????
????????</script>
????</head>
????<body?onload="Init();">
????</body>
</html>
轉(zhuǎn)載于:https://www.cnblogs.com/yitianhe/archive/2012/09/21/2696563.html
總結(jié)
以上是生活随笔為你收集整理的Skyline软件二次开发初级——3如何在WEB页面中的三维地图上创建几何对象的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 献给初学者-DSP入门教程
- 下一篇: RS232协议与RS485协议原理以及应