# LabelGraphics

#### new Cesium.LabelGraphics(options)
DataSources/LabelGraphics.js 54

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

Example labels

Name | Type | Description
--- | --- | ---

`options`

Object

optional Object with the following properties:

Name | Type | Default | Description
--- | --- | --- | ---
`show` | Property | `true` | optional A boolean Property specifying the visibility of the label.
`text` | Property |  | optional A Property specifying the text. Explicit newlines '\n' are supported.
`font` | Property | `'30px sans-serif'` | optional A Property specifying the CSS font.
`style` | Property | `LabelStyle.FILL` | optional A Property specifying the `LabelStyle`.
`scale` | Property | `1.0` | optional A numeric Property specifying the scale to apply to the text.
`showBackground` | Property | `false` | optional A boolean Property specifying the visibility of the background behind the label.
`backgroundColor` | Property | `new Color(0.165, 0.165, 0.165, 0.8)` | optional A Property specifying the background `Color`.
`backgroundPadding` | Property | `new Cartesian2(7, 5)` | optional A `Cartesian2` Property specifying the horizontal and vertical background padding in pixels.
`pixelOffset` | Property | `Cartesian2.ZERO` | optional A `Cartesian2` Property specifying the pixel offset.
`eyeOffset` | Property | `Cartesian3.ZERO` | optional A `Cartesian3` Property specifying the eye offset.
`horizontalOrigin` | Property | `HorizontalOrigin.CENTER` | optional A Property specifying the `HorizontalOrigin`.
`verticalOrigin` | Property | `VerticalOrigin.CENTER` | optional A Property specifying the `VerticalOrigin`.
`heightReference` | Property | `HeightReference.NONE` | optional A Property specifying what the height is relative to.
`fillColor` | Property | `Color.WHITE` | optional A Property specifying the fill `Color`.
`outlineColor` | Property | `Color.BLACK` | optional A Property specifying the outline `Color`.
`outlineWidth` | Property | `1.0` | optional A numeric Property specifying the outline width.
`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.
`scaleByDistance` | Property |  | optional A `NearFarScalar` Property used to set scale based on distance from the camera.
`distanceDisplayCondition` | Property |  | optional A Property specifying at what distance from the camera that this label will be displayed.
`disableDepthTestDistance` | Property |  | optional A Property specifying the distance from the camera at which to disable the depth test to.

##### Demo:

- Cesium Sandcastle Labels Demo

### Members

#### avoidance : Property
DataSources/LabelGraphics.js 129

Gets or sets the boolean Property specifying the avoidance of the label.

#### backgroundColor : Property
DataSources/LabelGraphics.js 184

Gets or sets the Property specifying the background `Color`.

Default Value: `new Color(0.165, 0.165, 0.165, 0.8)`

#### backgroundPadding : Property
DataSources/LabelGraphics.js 193

Gets or sets the `Cartesian2` Property specifying the label's horizontal and vertical background padding in pixels.

Default Value: `new Cartesian2(7, 5)`

#### readonlydefinitionChanged : Event
DataSources/LabelGraphics.js 111

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

#### disableDepthTestDistance : Property
DataSources/LabelGraphics.js 330

Gets or sets the distance from the camera at which to disable the depth test to, for example, prevent clipping against terrain. When set to zero, the depth test is always applied. When set to Number.POSITIVE_INFINITY, the depth test is never applied.

#### distanceDisplayCondition : Property
DataSources/LabelGraphics.js 322

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

#### eyeOffset : Property
DataSources/LabelGraphics.js 238

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);`

Default Value: `Cartesian3.ZERO`

#### fillColor : Property
DataSources/LabelGraphics.js 267

Gets or sets the Property specifying the fill `Color`.

#### font : Property
DataSources/LabelGraphics.js 145

Gets or sets the string Property specifying the font in CSS syntax.

##### See:

- CSS font on MDN

#### heightReference : Property
DataSources/LabelGraphics.js 260

Gets or sets the Property specifying the `HeightReference`.

Default Value: `HeightReference.NONE`

#### horizontalOrigin : Property
DataSources/LabelGraphics.js 245

Gets or sets the Property specifying the `HorizontalOrigin`.

#### outlineColor : Property
DataSources/LabelGraphics.js 274

Gets or sets the Property specifying the outline `Color`.

#### outlineWidth : Property
DataSources/LabelGraphics.js 281

Gets or sets the numeric Property specifying the outline width.

#### pixelOffset : Property
DataSources/LabelGraphics.js 213

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.

Default Value: `Cartesian2.ZERO`

#### pixelOffsetScaleByDistance : Property
DataSources/LabelGraphics.js 303

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.

#### scale : Property
DataSources/LabelGraphics.js 168

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`.

Default Value: `1.0`

#### scaleByDistance : Property
DataSources/LabelGraphics.js 315

Gets or sets near and far scaling properties of a Label based on the label's distance from the camera. A label's scale 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 scale remains clamped to the nearest bound. If undefined, scaleByDistance will be disabled.

#### show : Property
DataSources/LabelGraphics.js 122

Gets or sets the boolean Property specifying the visibility of the label.

#### showBackground : Property
DataSources/LabelGraphics.js 176

Gets or sets the boolean Property specifying the visibility of the background behind the label.

Default Value: `false`

#### style : Property
DataSources/LabelGraphics.js 152

Gets or sets the Property specifying the `LabelStyle`.

#### text : Property
DataSources/LabelGraphics.js 137

Gets or sets the string Property specifying the text of the label. Explicit newlines '\n' are supported.

#### translucencyByDistance : Property
DataSources/LabelGraphics.js 292

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.

#### verticalOrigin : Property
DataSources/LabelGraphics.js 252

Gets or sets the Property specifying the `VerticalOrigin`.

### Methods

#### clone(result) → LabelGraphics
DataSources/LabelGraphics.js 339

Duplicates this instance.

Name | Type | Description
--- | --- | ---
`result` | LabelGraphics | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new instance if one was not provided.

#### merge(source)
DataSources/LabelGraphics.js 374

Assigns each unassigned property on this object to the value of the same property on the provided source object.

Name | Type | Description
--- | --- | ---
`source` | LabelGraphics | The object to be merged into this object.