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

  • position LngLatLike 标注位置

  • zooms [number, number]? 标注显示级别,默认[0-22]

  • opacity number? 默认1

  • zIndex number? 默认1

  • icon Object? 图标

    • icon.image string? 图标地址:默认 "string", 禁用图标时,设置为空字符串
    • icon.size (number | [number, number])? 图标大小,倍数或指定宽高:scale | [width, height], 默认[46 * 0.6, 66 * 0.6],
    • icon.anchor Anchor? 默认bottom
    • icon.offset [number, number]? 默认[0, -4]
  • text Object? 文字

    • text.content string? 文字内容, 禁用文字时,设置为空字符串

    • text.direction TextDirection? 默认 top

    • text.offset number? 相对direction的位置偏移

    • text.style Object? 文字样式

      • text.style.fontSize number? 默认12
      • text.style.fillColor string? 默认#000