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 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

参数名必选类型描述
positionLngLatLike标注位置
zooms[number, number]标注显示级别,默认[0-22]
opacitynumber透明度,默认1
zIndexnumber层级,默认1
iconObject图标配置
icon.imagestring图标地址,禁用图标时设置为空字符串
icon.sizenumber | [number, number]图标大小,倍数或指定宽高,默认[27.6, 39.6]
icon.anchorAnchor图标锚点,默认bottom
icon.offset[number, number]图标偏移,默认[0, -4]
textObject文字配置
text.contentstring文字内容,禁用文字时设置为空字符串
text.directionTextDirection文字方向,默认top
text.offsetnumber相对方向的偏移
text.styleObject文字样式
text.style.fontSizenumber字体大小,默认12
text.style.fillColorstring填充颜色,默认#000