Skip to content

LabelMarker ​

LabelMarker ​

标注类,支持大量点标注和文本标注的绘制,基于LabelLayer图层绘制

继承SymbolFeature

Examples ​

javascript
const labelMarker = new DiMap.LabelMarker({
  position: [116.405467, 39.907761],
  zooms: [0, 22],
  opacity: 1,
  zIndex: 1,
  icon: {
    image: "https://xxx.com/marker.png",
    size: [46 * 0.6, 66 * 0.6],
    anchor: "bottom",
    offset: [0, 4]
  },
  text: {
    content: "文字内容",
    direction: "top",
    offset: 0,
    style: {
      fontSize: 12,
      fillColor: "#000"
    }
  }
})
const labelLayer = new DiMap.LabelLayer({
 visible: true,
 opacity: 1,
 collision: true,
 zooms: [0, 22]
})
labelLayer.add(labelMarker)
labelLayer.addToMap(map)

constructor ​

Parameters ​

setLabelMarkerOptions ​

设置标注属性

Parameters ​

Returns this

getLabelMarkerOptions ​

获取标注属性

Returns LabelMarkerOptions 标注属性

getPosition ​

获取标注位置

Returns LngLatLike 标注位置

show ​

显示标注

Returns this

hide ​

隐藏标注

Returns this

TextDirection ​

文字方向

Type: string

Properties ​

  • left "left" 左
  • right "right" 右
  • top "top" 上
  • bottom "bottom" 下

LabelMarkerOptions ​

标注属性

Properties ​

参数名必选类型描述
position是LngLatLike标注位置
zooms否[number, number]标注显示级别,默认[0-22]
opacity否number透明度,默认1
zIndex否number层级,默认1
icon否Object图标配置
icon.image否string图标地址,禁用图标时设置为空字符串
icon.size否number | [number, number]图标大小,倍数或指定宽高,默认[27.6, 39.6]
icon.anchor否Anchor图标锚点,默认bottom
icon.offset否[number, number]图标偏移,默认[0, -4]
text否Object文字配置
text.content否string文字内容,禁用文字时设置为空字符串
text.direction否TextDirection文字方向,默认top
text.offset否number相对方向的偏移
text.style否Object文字样式
text.style.fontSize否number字体大小,默认12
text.style.fillColor否string填充颜色,默认#000