The CreateLabel method creates a label in the 3D Window.
The method offers an optimization point in the LabelInfo parameter for JavaScript programmers. The parameter allows the client to set all of the label properties at the label creation time. When creating a large numbers of labels at once, CreateLabel avoids unnecessary round-trips between the client and TerraExplorer and therefore gains in performance.
HRESULT CreateLabel (
[in] VARIANT LabelInfo,
[in] double X,
[in] double Y,
[in] double Elevation,
[in, defaultvalue(0)] HeightStyleCode HeightStyle,
[in, defaultvalue(0)] long GroupID,
[in, defaultvalue("")] BSTR Description,
[out, retval] ITerrainLabel5** pITerrainLabel5)
Parameters:
LabelInfo – An object
containing all or part of the label properties settings. Use -1 if
no information is passed.
See: ITerrainLable::GetLabelStruct() method for
details about this structure and “Creating a Label Using an
Object” for an example code in JavaScript.
Note: This parameter is built for use from JavaScript
code.
X – The West-East coordinate of the center of the label represented in MPT units. You can use the ITerrain interface to retrieve information about the MPT units. If you are working in Lat-Long format, the Lat-Long values are in decimal Lat-Long.
Y – The North-South coordinate of the center of the label represented in MPT units. You can use the ITerrain interface to retrieve information about the MPT units. If you are working in Lat-Long format, the Lat-Long values are in decimal Lat-Long.
Elevation – The elevation of the label relative to the terrain.
HeightStyle – An enum determining how the label is placed on the terrain.
The HeightStyleCode enum can use any of the following values:
HSC_TERRAIN_RELATIVE = 0
The height above the terrain of the label’s pivot (the center of
its base), is determined by the Elevation points in the
SafeArrayVertices parameter.
HSC_TERRAIN_ABSOLUTE = 3
The height relative to the terrain database vertical datum base
ellipsoid of the label’s pivot (the center of its base), is
determined by the Elevation points in the SafeArrayVertices
parameter.
GroupID – The Information Tree group in which the label is created. If it is set to zero, the object is created under the root. You can obtain the GroupID by one of the following methods:
Create the group the IInformationTree5::CreateGroup.
If you know the name of the group, find it using IInformationTree5::FindItem.
Traverse the Tree using IInformationTree5 methods such as GetNextItem, until you come to the desired GroupID.
Description – The name of the label as it appears in the Information Window. If an empty string is passed into this parameter, TerraExplorer assigns it a unique name.
pITerrainLabel5 – An interface pointer to the newly created label. This parameter must not be Null.
Return Values:
The return value obtained from the returned HRESULT can be one of the following:
Return value |
Meaning |
S_OK |
Success. |
E_FAIL |
Catastrophic failure. |
TE_E_MPTNOTLOADED |
An MPT file must be loaded in TerraExplorer for this method to work. |
TE_E_INFOTREE_PARENTNOTGROUP |
The group ID entered does not represent a valid group in the information tree. |
TE_E_INTERNAL |
TerraExplorer was unable to create the object. To get more information about this error use the IErrorInfo Interface. |
TE_E_NOLICENCE |
Your license does not allow the use of this feature. |
Remarks:
After this method call returns, the label is not yet visible on the terrain. The client must first set either ITerrainLabel5::Text or ITerrainLabel5::ImageFileName (or both) properties.