Class: CustomLabel

CustomLabel

自定义文字标签,可以用于绘制带有垂直标记线的文字标签

// 添加图层
const layer = new EntityLayer().addToViewer(this.$viewer);
const customLabel = new CustomLabel(
  new Position(118.78600228, 31.9135434, 1.66113721),
  "启业云南京大数据",
  20
).addToLayer(layer);
customLabel.setStyle({
  showBackground: true,
  backgroundColor: Color.fromCssColor("rgba(47, 53, 60, 0.8)"),
  verticalOrigin: 1,
  font: "16px 宋体"
});
customLabel.setVLine({
  width: 2,
  material: new PolylineDashMaterialProperty({
    color: Color.YELLOW
  })
});
// 注册 customLabel 鼠标移入事件
customLabel.on(MouseEventType.CLICK, evt => {
  console.log(evt);
});

new CustomLabel(position, text, height)

overlay/custom/CustomLabel.js, line 50
Name Type Default Description
position Position

坐标

text String

文本内容

height Number 30 optional

标记线的长度(高度)

Extends

Classes

CustomLabel

Members

attr

覆盖物的额外属性设置

readonlydelegate

覆盖物的代理对象

id

设置覆盖物的业务 id

readonlyoverlayEvent

覆盖物的事件对象

readonlyoverlayId

覆盖物唯一标识

show

覆盖物的可见性

readonlystate

覆盖物的状态

Methods

inherited addToLayer(layer){Overlay}

overlay/Overlay.js, line 242

添加到指定图层

Name Type Description
layer EntityLayer

指定图层

Returns:
Type Description
Overlay

inherited fire(type, params){Overlay}

overlay/Overlay.js, line 282

触发事件

Name Type Description
type *
params *
Returns:
Type Description
Overlay

inherited off(type, callback, context){Overlay}

overlay/Overlay.js, line 270

注销事件

Name Type Description
type *

事件类型

callback *

监听回调

context *
Returns:
Type Description
Overlay

inherited on(type, callback, context){Overlay}

overlay/Overlay.js, line 257

注册事件

Name Type Description
type *

事件类型

callback *

监听回调

context *
Returns:
Type Description
Overlay

inherited remove(){Overlay}

overlay/Overlay.js, line 229

从图层上移出

Returns:
Type Description
Overlay

setBottomCircle(radius, style, rotateAmount){CustomLabel}

overlay/custom/CustomLabel.js, line 160

设置底部圆样式

Name Type Description
radius Number

半径

style Object

样式可选属性

rotateAmount Number

旋转角度

Returns:
Type Description
CustomLabel

inherited setLabel(text, textStyle){Overlay}

overlay/Overlay.js, line 205

设置文字标签

Name Type Description
text Property | string

指定文本的属性。支持显式换行符'\ n'。

textStyle Object

text 样式

Returns:
Type Description
Overlay

setStyle(style){CustomLabel}

overlay/custom/CustomLabel.js, line 116

设置 CustomLabel 的样式,参照Label#setStyle

Name Type Description
style Object

样式可选属性

Returns:
Type Description
CustomLabel

setVLine(style){CustomLabel}

overlay/custom/CustomLabel.js, line 132

设置垂直线的样式,参照Polyline#setStyle

Name Type Description
style Object

样式可选属性

Returns:
Type Description
CustomLabel