1. Save:
<HTML>
<Head>
<Title> saving </title>
<Object ID = "sgworld" classid = "CLSID: 3a4f91b1-65a8-11d5-85c1-0001023952c1" style = "visibility: hidden; Height: 0"> </Object>
<SCRIPT type = "text/JavaScript">
Function Init ()
{
VaR group = createpolygons ();
Alert ("Click OK to save the polygons ");
// This can be done on any group node.
Try
{
VaR ret = sgworld. projecttree. saveasfly ("mywork. Fly", group );
Alert ("the polygons were successfully saved to:" + RET );
}
Catch (E)
{
Alert ("error: the polygons were not saved \ r \ ndescription:" + E. Description );
}
}
Function createpolygons ()
{
VaR group = sgworld. projecttree. creategroup ("polygons ");
VaR pointsusuah = 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 ))");
// 2 in altitudetypecode means on terrain, 0 means add to root
VaR polyutah = sgworld. creator. createpolygon (pointsuah, "# ff0000", sgworld. creator. createcolor (0,255,255, 40), 2, group, "Utah ");//
Polyutah. linestyle. width = 5000; // 5000 m (5 km)
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, group, "Wyoming ");
Polywyoming. linestyle. width = 20000; // 20000 m (20 km)
Polywyoming. position. Distance = 1600000;
Sgworld. Navigate. flyto (polywyoming );
Return group;
}
</SCRIPT>
</Head>
<Body onload = "Init ();">
</Body>
</Html>
2. Load:
<HTML>
<Head>
<Title> loading </title>
<Object ID = "sgworld" classid = "CLSID: 3a4f91b1-65a8-11d5-85c1-0001023952c1" style = "visibility: hidden; Height: 0"> </Object>
<SCRIPT type = "text/JavaScript">
Function Init ()
{
Alert ("Click OK to load the polygons ");
VaR id = sgworld. projecttree. loadflylayer (sgworld. application. datapath + "\ mywork. Fly ");
Sgworld. Navigate. flyto (sgworld. creator. createposition (-109.51449, 32.85615, 1500000, 0,-60 ));
}
</SCRIPT>
</Head>
<Body onload = "Init ();">
</Body>
</Html>