描述位于包含位置的二维标签 Describes a two dimensional label located at the position of the containing

标签示例 Example labels
Entity.

标签示例 Example labels
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
options |
LabelGraphics.ConstructorOptions | 可选 optional 描述初始化选项的对象 Object describing initialization options |
演示: Demo:
成员 Members
backgroundColor : Property|undefined
获取或设置指定背景的属性 Gets or sets the Property specifying the background
Color.
-
默认值: Default Value:
new Color(0.165, 0.165, 0.165, 0.8)
backgroundPadding : Property|undefined
获取或设置 Gets or sets the
Cartesian2 属性指定标签的水平和垂直背景填充(以像素为单位)。 Property specifying the label's horizontal and vertical background padding in pixels.
-
默认值: Default Value:
new Cartesian2(7, 5)
readonly definitionChanged : Event
获取每当更改或修改属性或子属性时引发的事件。 Gets the event that is raised whenever a property or sub-property is changed or modified.
disableDepthTestDistance : Property|undefined
获取或设置禁用深度测试的距相机的距离,例如,防止对地形进行裁剪。当设置为零时,始终应用深度测试。当设置为 Number.POSITIVE_INFINITY 时,永远不会应用深度测试。 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|undefined
获取或设置 Gets or sets the
DistanceDisplayCondition 属性指定该标签将在距相机的距离处显示。 Property specifying at what distance from the camera that this label will be displayed.
eyeOffset : Property|undefined
获取或设置 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.
眼睛偏移通常用于将多个标签或对象排列在同一位置,例如,将标签排列在其相应的 3D 模型上方。 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|undefined
获取或设置指定填充的属性 Gets or sets the Property specifying the fill
Color.
font : Property|undefined
获取或设置以 CSS 语法指定字体的字符串属性。 Gets or sets the string Property specifying the font in CSS syntax.
另见: See:
heightReference : Property|undefined
获取或设置指定的属性 Gets or sets the Property specifying the
HeightReference.
-
默认值: Default Value:
HeightReference.NONE
horizontalOrigin : Property|undefined
获取或设置指定的属性 Gets or sets the Property specifying the
HorizontalOrigin.
outlineColor : Property|undefined
获取或设置指定轮廓的属性 Gets or sets the Property specifying the outline
Color.
outlineWidth : Property|undefined
获取或设置指定轮廓宽度的数字属性。 Gets or sets the numeric Property specifying the outline width.
pixelOffset : Property|undefined
获取或设置 Gets or sets the
标签的来源由黄点指示。 The label's origin is indicated by the yellow point.
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); |
-
默认值: Default Value:
Cartesian2.ZERO
pixelOffsetScaleByDistance : Property|undefined
获取或设置 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 lower and upper 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|undefined
获取或设置指定要应用于图像的统一比例的数字属性。规模大于 Gets or sets the numeric Property specifying the uniform scale to apply to the image. A scale greater than

上图中从左到右,比例尺分别是 From left to right in the above image, the scales are
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|undefined
根据标签与相机的距离获取或设置 Label 的近缩放属性和远缩放属性。标签的比例将在 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 lower and upper bounds of the specified NearFarScalar#near and NearFarScalar#far。在这些范围之外,标签的比例仍然被限制在最近的范围内。 If undefined, scaleByDistance will be disabled. . Outside of these ranges the label's scale remains clamped to the nearest bound. If undefined, scaleByDistance will be disabled.
show : Property|undefined
获取或设置指定标签可见性的布尔属性。 Gets or sets the boolean Property specifying the visibility of the label.
showBackground : Property|undefined
获取或设置指定标签后面背景的可见性的布尔属性。 Gets or sets the boolean Property specifying the visibility of the background behind the label.
-
默认值: Default Value:
false
style : Property|undefined
获取或设置指定的属性 Gets or sets the Property specifying the
LabelStyle.
text : Property|undefined
获取或设置指定标签文本的字符串属性。支持显式换行符 '\n'。 Gets or sets the string Property specifying the text of the label. Explicit newlines '\n' are supported.
translucencyByDistance : Property|undefined
获取或设置 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 lower and upper 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|undefined
获取或设置指定的属性 Gets or sets the Property specifying the
VerticalOrigin.
方法 Methods
clone(result) → LabelGraphics
复制此实例。 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.
将此对象上每个未分配的属性分配给所提供的源对象上相同属性的值。 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. |
类型定义 Type Definitions
LabelGraphics 构造函数的初始化选项 Initialization options for the LabelGraphics constructor
属性: Properties:
| 名称 Name | 类型 Type | Attributes | 默认值 Default | 说明 Description |
|---|---|---|---|---|
show |
Property | boolean |
<可选> <optional> |
true | 指定标签可见性的布尔属性。 A boolean Property specifying the visibility of the label. |
text |
Property | string |
<可选> <optional> |
指定文本的属性。支持显式换行符 '\n'。 A Property specifying the text. Explicit newlines '\n' are supported. | |
font |
Property | string |
<可选> <optional> |
'30px 无衬线' '30px sans-serif' | 指定 CSS 字体的属性。 A Property specifying the CSS font. |
style |
Property | LabelStyle |
<可选> <optional> |
LabelStyle.FILL | 指定的属性 A Property specifying the LabelStyle. |
scale |
Property | number |
<可选> <optional> |
1.0 | 一个数字属性,指定应用于文本的比例。 A numeric Property specifying the scale to apply to the text. |
showBackground |
Property | boolean |
<可选> <optional> |
false | 一个布尔属性,指定标签后面的背景的可见性。 A boolean Property specifying the visibility of the background behind the label. |
backgroundColor |
Property | Color |
<可选> <optional> |
新颜色(0.165, 0.165, 0.165, 0.8) new Color(0.165, 0.165, 0.165, 0.8) | 指定背景的属性 A Property specifying the background Color. |
backgroundPadding |
Property | Cartesian2 |
<可选> <optional> |
新笛卡尔2(7, 5) new Cartesian2(7, 5) | A Cartesian2 属性指定水平和垂直背景填充(以像素为单位)。 Property specifying the horizontal and vertical background padding in pixels. |
pixelOffset |
Property | Cartesian2 |
<可选> <optional> |
Cartesian2.ZERO | A Cartesian2 指定像素偏移的属性。 Property specifying the pixel offset. |
eyeOffset |
Property | Cartesian3 |
<可选> <optional> |
Cartesian3.ZERO | A Cartesian3 指定眼睛偏移的属性。 Property specifying the eye offset. |
horizontalOrigin |
Property | HorizontalOrigin |
<可选> <optional> |
HorizontalOrigin.CENTER | 指定的属性 A Property specifying the HorizontalOrigin. |
verticalOrigin |
Property | VerticalOrigin |
<可选> <optional> |
VerticalOrigin.CENTER | 指定的属性 A Property specifying the VerticalOrigin. |
heightReference |
Property | HeightReference |
<可选> <optional> |
HeightReference.NONE | 指定高度相对值的属性。 A Property specifying what the height is relative to. |
fillColor |
Property | Color |
<可选> <optional> |
Color.WHITE | 指定填充的属性 A Property specifying the fill Color. |
outlineColor |
Property | Color |
<可选> <optional> |
Color.BLACK | 指定轮廓的属性 A Property specifying the outline Color. |
outlineWidth |
Property | number |
<可选> <optional> |
1.0 | 指定轮廓宽度的数字属性。 A numeric Property specifying the outline width. |
translucencyByDistance |
Property | NearFarScalar |
<可选> <optional> |
A NearFarScalar 用于根据距相机的距离设置半透明度的属性。 Property used to set translucency based on distance from the camera. |
|
pixelOffsetScaleByDistance |
Property | NearFarScalar |
<可选> <optional> |
A NearFarScalar 用于根据距相机的距离设置 PixelOffset 的属性。 Property used to set pixelOffset based on distance from the camera. |
|
scaleByDistance |
Property | NearFarScalar |
<可选> <optional> |
A NearFarScalar 用于根据距相机的距离设置比例的属性。 Property used to set scale based on distance from the camera. |
|
distanceDisplayCondition |
Property | DistanceDisplayCondition |
<可选> <optional> |
一个属性,指定该标签将在距相机的距离处显示。 A Property specifying at what distance from the camera that this label will be displayed. | |
disableDepthTestDistance |
Property | number |
<可选> <optional> |
指定禁用深度测试的距相机距离的属性。 A Property specifying the distance from the camera at which to disable the depth test to. |


