Creates a new polygon object on the terrain.
createPolygon(vertices, [lineColor], [fillColor], [name], [heightType]);
Parameter |
Description |
vertices |
Array of SGCoord3D, SGCoord2D, SGPosition or numbers. If the array is composed of numbers, the numbers must be as follows: x1, h1, y1, x2, h2, y2… |
lineColor |
Optional, default: sgLime The color of the object outline Can be one of the following: SGColor, HTML color string (e.g., “#FF0000”), a number that represents ABGR color (e.g., 0xAA0000FF) or one of the predefined Skyline Globe colors (e.g., sgRed). For a complete list of the pre defined colors, see Skyline Globe Colors |
fillColor |
Optional, default: sgDimgray The color of the object filling Can be one of the following: SGColor, HTML color string (e.g., “#FF0000”), a number that represents ABGR color (e.g., 0xAA0000FF) or one of the predefined Skyline Globe colors (e.g., sgRed). For a complete list of the predefined colors, see Skyline Globe Colors |
name |
Optional The node name |
heightType |
Optional, default: sgHeightOnTerrain Determines how the polyline is placed on the terrain Can be one of the following: sgHeightOnTerrain - the vertices are placed on the terrain sgHeightRelative- each of the polyline vertices has a height relative to the terrain sgHeightAbsolute - each of the polyline vertices has a height relative to the terrain database vertical datum base ellipsoid |
Return Value
An SGNode object. If the method fails, the return value is null. SGWorld.lastError will contain the failure reason.
Remarks
To modify other properties of the polygon such as line width, access the node innerObj. See SGNode.innerObj property and ITerrainPolyline5 interface for more details.
The default polygon is drawn on the terrain surface, heightType is sgHeightOnTerrain. To create a polygon in the air select sgHeightRelative or sgHeightAbsolute.
Example
The following example illustrates the use of the createPolygon method.
function createPolygon()
{
var pointsUtah = new Array(
new SGCoord2D(-114.03822,41.99547),
new SGCoord2D(-111.04795,41.99626),
new SGCoord2D(-111.05028,40.99663),
new SGCoord2D(-109.04763,40.99847),
new SGCoord2D(-109.04782,36.99664),
new SGCoord2D(-114.04313,36.99656)
);
var polyUtah = globe.creator.createPolygon(
pointsUtah,
sgYellow,
new SGColor(100,255,200, 0.5),
"my poly"
);
polyUtah.innerObj.LineWidth = 20000; // 20000m (20km)
globe.root.appendChild(polyUtah);
globe.navigate.flyTo(polyUtah);
}