new Cesium.LabelGraphics(options)

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


Example labels

Name Type Description
options LabelGraphics.ConstructorOptions optional 描述初始化选项的对象
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 以像素粘贴背景.
Default Value: new Cartesian2(7, 5)

readonly definitionChanged : Event

当财产或次级财产被改变或修改时,获取该事件.

disableDepthTestDistance : Property|undefined

获取或设定相机的距离,以禁用深度测试,例如防止对地形进行剪切. 当设定为零时,总是应用深度测试. 当设定为 Number.POSITIVE_INFINITY 时,深度测试从未应用.

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. 眼坐标是一个左手坐标系统,其中 NT 0 x NT 1 指向观看者 右, NT 0 y NT 1 积分上方, NT 2 z NT 3 积分进入屏幕 .

眼部偏移通常用于在同一位置排列多个标签或对象, e.g 在相应的3D模型上方安排标签.

下方的标签位于地球中心 但眼球的偏移使它永远 无论观众或地球的定位如何 都出现在地球顶部.

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

获取或设置字符串属性,在 NT 0 语法中指定字体.
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

获取或设置指定大纲宽度的数值属性.

pixelOffset : Property|undefined

Gets or sets the Cartesian2 Property specifying the label's pixel offset in screen space 从此标签的来源。 这通常用于在 the same position, e.g., an image and text. The screen space origin is the top, left corner of the 画布; NT 0 x NT 1 由左向右增加, NT 2 y NT 3 由上向下增加.

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. 标签的像素偏移将在 {NT}\\\ 和\ \ \ \ \ \ \ \ \ \ \ \ \ \ 和 NearFarScalar#farValue while the camera distance falls within the lower and upper bounds of the specified NearFarScalar#near and NearFarScalar#far. 在这些范围之外,标签的像素偏移仍被夹在最接近的边框上.

scale : Property|undefined

获取或设置指定适用于图像的统一比例尺的数字属性. 大于 NT 0 1.0 NT 1 1 的缩放,而小于 NT 2 1.0 NT 3 的缩放.


从左到右在以上图像中,比例尺为 NT 0 0.5 NT 1 , NT 2 1.0 NT Q 3 ,....., 和 2.0 .

Default Value: 1.0

scaleByDistance : Property|undefined

根据标签与相机的距离,获取或设定一个标签的近和远的缩放属性. 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. 在这些区域之外,标签的尺寸仍被限制在最接近的界限内。 如果未定义, 缩放ByDistance 将被禁用.

show : Property|undefined

获取或设置指定标签可见度的布尔属性 .

showBackground : Property|undefined

获取或设置指定标签后面背景可见度的布尔属性 .
Default Value: false

style : Property|undefined

Gets or sets the Property specifying the LabelStyle.

text : Property|undefined

获取或设置指定标签文本的字符串属性. 支持明确的新行“\n” .

translucencyByDistance : Property|undefined

Gets or sets NearFarScalar Property specifying the translucency of the label based on the distance from the camera. 标签的透明度会在 {NT}\\\ 和\ \ \ \ \ \ \ \ \ \ \ \ 和\ \ \ \ \ \ \ \ \ \ \ \ \ \ 和\ \ \ \ \ \ \ \ \ 和 NearFarScalar#farValue while the camera distance falls within the lower and upper bounds of the specified NearFarScalar#near and NearFarScalar#far. 在这些范围以外,标签的透明度仍然被限制在最接近的界限上.

verticalOrigin : Property|undefined

Gets or sets the Property specifying the VerticalOrigin.

Methods

clone(result)LabelGraphics

重复这个例子.
Name Type Description
result LabelGraphics optional 存储结果的对象 .
Returns:
未提供修改的结果参数或新实例 .

merge(source)

指定该对象上每个未指定属性的值 - 提供源对象上的同一财产.
Name Type Description
source LabelGraphics 要合并成此天体的对象.

Type Definitions

Cesium.LabelGraphics.ConstructorOptions

LabelGraphics 构建器的初始化选项
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” .
font Property | string <optional>
'30px sans-serif' 一个属性,指定了 NT 0 字体.
style Property | LabelStyle <optional>
LabelStyle.FILL A Property specifying the LabelStyle.
scale Property | number <optional>
1.0 指定适用于文本的尺度的数字属性.
showBackground Property | boolean <optional>
false A boolean Property specifying the visibility of the background behind the label.
backgroundColor Property | Color <optional>
new Color(0.165, 0.165, 0.165, 0.8) A Property specifying the background Color.
backgroundPadding Property | Cartesian2 <optional>
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 指定大纲宽度的数字属性.
translucencyByDistance Property | NearFarScalar <optional>
A NearFarScalar Property used to set translucency based on distance from the camera.
pixelOffsetScaleByDistance Property | NearFarScalar <optional>
A NearFarScalar 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>
指定显示此标签的相机距离的属性 .
disableDepthTestDistance Property | number <optional>
指定从相机到深度测试的距离的属性 .
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.