createLabel Method

Creates a new label composed of a text and an image on the terrain.

createLabel(position, text, imageURL, [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

imageURL

The URL of the image to appear on the label

Passing null in this parameter creates a text label only (the same as in createTextLabel method).

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 and 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 label, access the node innerObj. See SGNode.innerObj property and ITerrainLabel5 interface for more details.

Example

The following example illustrates the use of the createLabel method.

 

function createLabel()

{

   var labelPos = new SGCoord3D(-122.41519, 37.74346, 100);  

 

   var label = globe.creator.createLabel(

               labelPos,

               "My Text",

               "http://www.myhomepage.com/myImage.gif"

               );

           

   globe.root.appendChild(label);

           

   globe.navigate.flyTo(label);

}