new Label(position, text)
overlay/base/Label.js, line 36
Name | Type | Description |
---|---|---|
position |
Position |
坐标 |
text |
String |
文本内容 |
Extends
Classes
Members
-
attr
-
覆盖物的额外属性设置
-
readonlydelegate
-
覆盖物的代理对象
-
id
-
设置覆盖物的业务 id
-
readonlyoverlayEvent
-
覆盖物的事件对象
-
readonlyoverlayId
-
覆盖物唯一标识
-
show
-
覆盖物的可见性
-
readonlystate
-
覆盖物的状态
Methods
-
staticLabel.fromEntity(entity){any}
overlay/base/Label.js, line 142 -
从 entity 中解析出 Label
Name Type Description entity
Entity Returns:
Type Description any -
添加到指定图层
Name Type Description layer
EntityLayer 指定图层
Returns:
Type Description Overlay -
触发事件
Name Type Description type
* params
* Returns:
Type Description Overlay -
注销事件
Name Type Description type
* 事件类型
callback
* 监听回调
context
* Returns:
Type Description Overlay -
注册事件
Name Type Description type
* 事件类型
callback
* 监听回调
context
* Returns:
Type Description Overlay -
从图层上移出
Returns:
Type Description Overlay -
设置文字标签
Name Type Description text
Property | string 指定文本的属性。支持显式换行符'\ n'。
textStyle
Object text 样式
Returns:
Type Description Overlay -
setStyle(style){Label}
overlay/base/Label.js, line 126 -
设置 Label 样式
Name Type Description style
Object 样式可选属性
// 样式参数(可选) { "text": "测试文本", // 文本内容 "font": "30px sans-serif", // CSS 字体设置 "style": 2, // 指定 label 绘制风格。`FILL: 0, OUTLINE: 1, FILL_AND_OUTLINE: 2` "scale": 1, //比例 "pixelOffset": { "x": 0, "y": 0 }, //偏移像素 "horizontalOrigin": 0, // 水平对齐方式。CENTER: 0, LEFT: 1, RIGHT: -1 "verticalOrigin": 0, // 垂直对齐方式。 CENTER: 0, BOTTOM: 1, BASELINE: 2, TOP: -1 "heightReference": 0, //高度参照,0:位置无参照,位置是绝对的,1:位置固定在地形上 2:位置高度是指地形上方的高度。 "showBackground": false, //是否显示背景 "backgroundColor":Color.BLACK, //背景颜色 "backgroundPadding": { "x": 0, "y": 0 }, //背景间隙 "fillColor": Color.BLACK, //文字颜色 "outlineColor": Color.WHITE, //边框颜色 "outlineWidth": 0, //边框大小, "scaleByDistance": { "near": 0, //最近距离 "nearValue": 0, //最近距离值 "far": 1, //最远距离值 "farValue": 0 //最远距离值 }, //根据距离设置比例 "translucencyByDistance": { "near": 0, //最近距离 "nearValue": 0, //最近距离值 "far": 1, //最远距离值 "farValue": 0 //最远距离值 }, //根据距离设置透明度 "distanceDisplayCondition": { "near": 0, //最近距离 "far": Number.MAX_VALUE //最远距离 }, //根据距离设置可见 "disableDepthTestDistance": 0 // 深度检测距离,用于防止剪切地形,设置为零时,将始终应用深度测试。设置为Number.POSITIVE_INFINITY时,永远不会应用深度测试。 }
Returns:
Type Description Label