Creates a new text label on the terrain.
createTextLabel(position, text, [labelStyle], [name]);
Parameter |
Description |
position |
The position of the object, defined by its coordinates in the 3D world Can be one of the following: SGCoord3D, SGCoord2D, SGPosition |
text |
The label text |
labelStyle |
Optional, default is an empty white text label An SGLabelStyle object The label style determines some of the label properties such as font, size, color and from what height it becomes visible. See SGLabelStyle object for a complete list of properties that can be applied using the label style |
name |
Optional The node name |
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 text label, access the node innerObj. See SGNode.innerObj property and ITerrainLabel5 interface for more details.
The simplest way to add labels to the terrain is to call createTextLabel method passing it the text and position.
Example
The following examples illustrate the use of the createTextLabel method.
function createSimpleTextLabel()
{
var label = globe.creator.createTextLabel(
new SGCoord3D(-122.41519, 37.74346, 50),
"My Simple Label"
);
globe.root.appendChild(label);
globe.navigate.flyTo(label);
}
function createTextLabel()
{
var labelStyle = new SGLabelStyle(sgYellow);
labelStyle.fontSize = 24;
labelStyle.fontName = "Times New Roman";
labelStyle.bold = true;
labelStyle.lineToGround = true;
var label = globe.creator.createTextLabel(
new SGCoord3D(-122.41519, 37.74346, 100),
"My Text",
labelStyle
);
globe.root.appendChild(label);
globe.navigate.flyTo(label);
}