Class: LabelGraphics

LabelGraphics

new LabelGraphics(optionsopt)

Describes a two dimensional label located at the position of the containing Entity.


Example labels

Parameters:
Name Type Attributes Description
options Object <optional>
Object with the following properties:
Properties
Name Type Attributes Default Description
text Property <optional>
A Property specifying the text.
font Property <optional>
'10px sans-serif' A Property specifying the CSS font.
style Property <optional>
LabelStyle.FILL A Property specifying the LabelStyle.
fillColor Property <optional>
Color.WHITE A Property specifying the fill Color.
outlineColor Property <optional>
Color.BLACK A Property specifying the outline Color.
outlineWidth Property <optional>
1.0 A numeric Property specifying the outline width.
show Property <optional>
true A boolean Property specifying the visibility of the label.
scale Property <optional>
1.0 A numeric Property specifying the scale to apply to the text.
horizontalOrigin Property <optional>
HorizontalOrigin.CENTER A Property specifying the HorizontalOrigin.
verticalOrigin Property <optional>
VerticalOrigin.CENTER A Property specifying the VerticalOrigin.
eyeOffset Property <optional>
Cartesian3.ZERO A Cartesian3 Property specifying the eye offset.
pixelOffset Property <optional>
Cartesian2.ZERO A Cartesian2 Property specifying the pixel offset.
translucencyByDistance Property <optional>
A NearFarScalar Property used to set translucency based on distance from the camera.
pixelOffsetScaleByDistance Property <optional>
A NearFarScalar Property used to set pixelOffset based on distance from the camera.
heightReference Property <optional>
HeightReference.NONE A Property specifying what the height is relative to.
distanceDisplayCondition Property <optional>
A Property specifying at what distance from the camera that this label will be displayed.
Source:

Members

(readonly) definitionChanged :Event

Gets the event that is raised whenever a property or sub-property is changed or modified.
Type:
Source:

distanceDisplayCondition :Property

Gets or sets the DistanceDisplayCondition Property specifying at what distance from the camera that this label will be displayed.
Type:
Source:

eyeOffset :Property

Gets or sets the Cartesian3 Property specifying the label's offset in eye coordinates. Eye coordinates is a left-handed coordinate system, where x points towards the viewer's right, y points up, and z points into the screen.

An eye offset is commonly used to arrange multiple labels or objects at the same position, e.g., to arrange a label above its corresponding 3D model.

Below, the label is positioned at the center of the Earth but an eye offset makes it always appear on top of the Earth regardless of the viewer's or Earth's orientation.

l.eyeOffset = new Cartesian3(0.0, 8000000.0, 0.0);

Type:
Default Value:
  • Cartesian3.ZERO
Source:

fillColor :Property

Gets or sets the Property specifying the fill Color.
Type:
Source:

font :Property

Gets or sets the string Property specifying the font in CSS syntax.
Type:
Source:
See:

heightReference :Property

Gets or sets the Property specifying the HeightReference.
Type:
Default Value:
  • HeightReference.NONE
Source:

horizontalOrigin :Property

Gets or sets the Property specifying the HorizontalOrigin.
Type:
Source:

outlineColor :Property

Gets or sets the Property specifying the outline Color.
Type:
Source:

outlineWidth :Property

Gets or sets the numeric Property specifying the outline width.
Type:
Source:

pixelOffset :Property

Gets or sets the Cartesian2 Property specifying the label's pixel offset in screen space from the origin of this label. This is commonly used to align multiple labels and labels at the same position, e.g., an image and text. The screen space origin is the top, left corner of the canvas; x increases from left to right, and y increases from top to bottom.

default
l.pixeloffset = new Cartesian2(25, 75);
The label's origin is indicated by the yellow point.

Type:
Default Value:
  • Cartesian2.ZERO
Source:

pixelOffsetScaleByDistance :Property

Gets or sets NearFarScalar Property specifying the pixel offset of the label based on the distance from the camera. A label's pixel offset will interpolate between the NearFarScalar#nearValue and NearFarScalar#farValue while the camera distance falls within the upper and lower bounds of the specified NearFarScalar#near and NearFarScalar#far. Outside of these ranges the label's pixel offset remains clamped to the nearest bound.
Type:
Source:

scale :Property

Gets or sets the numeric Property specifying the uniform scale to apply to the image. A scale greater than 1.0 enlarges the label while a scale less than 1.0 shrinks it.


From left to right in the above image, the scales are 0.5, 1.0, and 2.0.

Type:
Default Value:
  • 1.0
Source:

show :Property

Gets or sets the boolean Property specifying the visibility of the label.
Type:
Source:

style :Property

Gets or sets the Property specifying the LabelStyle.
Type:
Source:

text :Property

Gets or sets the string Property specifying the text of the label.
Type:
Source:

translucencyByDistance :Property

Gets or sets NearFarScalar Property specifying the translucency of the label based on the distance from the camera. A label's translucency will interpolate between the NearFarScalar#nearValue and NearFarScalar#farValue while the camera distance falls within the upper and lower bounds of the specified NearFarScalar#near and NearFarScalar#far. Outside of these ranges the label's translucency remains clamped to the nearest bound.
Type:
Source:

verticalOrigin :Property

Gets or sets the Property specifying the VerticalOrigin.
Type:
Source:

Methods

clone(resultopt) → {LabelGraphics}

Duplicates this instance.
Parameters:
Name Type Attributes Description
result LabelGraphics <optional>
The object onto which to store the result.
Source:
Returns:
The modified result parameter or a new instance if one was not provided.
Type
LabelGraphics

merge(source)

Assigns each unassigned property on this object to the value of the same property on the provided source object.
Parameters:
Name Type Description
source LabelGraphics The object to be merged into this object.
Source: