Initializes a new instance of the SGWorld class.
Using SGAPI requires an include tag in your HTML, pointing to the SGAPI sources. You can reference specific URL of the sources, e.g., "<script
src="http://www.skylinesoft.com/SGAPI/v2.0/sgapi.js"></script>", or use the generic "<script src="skyline:sgapi.js"></script>" that uses the local copy of SGAPI sources installed with your copy of TerraExplorer.
var globe = new SGWorld([divID]);
Parameter |
Description |
divID |
Optional div id in the HTML page, where the SGWorld control renders its content |
Remarks
The above parameters are required only when writing a page that contains the div hosting the control. Otherwise, the SGWorld object can be initiated, and work can start. The SGWorld object then detects the existing div by itself.
Example
The following two examples illustrate the two different uses of the constructor.
In the first example, the website is already hosting a SkylineGlobe control (e.g., in another frame) and we only need to make use of it.
<html>
<head>
<title>SGAPI Sample</title>
<script src="skyline:sgapi.js"></script>
<script language="jscript">
var globe = null;
function Init()
{
try
{
globe = new SGWorld();
globe.root.setName("MyTool");
globe.navigate.setPosition(new SGPosition(-71.07596, 42.34998, 100));
}
catch(e)
{
alert(e.description);
}
}
</script>
</head>
<body onload="Init();">
</body>
</html>
The following example shows the page hosting the SkylineGlobe control.
<html>
<head>
<title>SGAPI Sample</title>
<script src="skyline:sgapi.js"></script>
<script language="jscript">
var globe = null;
function init()
{
try
{
globe = new SGWorld("myWorld");
globe.teCore.ITerraExplorer.Load("C:\\MyFly.fly");
}
catch(e)
{
alert(e.description);
}
}
</script>
</head>
<body onload="init();">
<div id='myWorld' style="position:relative; width:700px; height:500px;"></div>
</body>
</html>