Skip to content

SymbolFeature

SymbolFeature

符号要素类

继承BaseFeature

Examples

javascript
const symbolFeature = new DiMap.SymbolFeature({
  geoData: [116.405467, 39.907761],
  symbolTextContent: "北京",
  symbolTextAnchor: "top",
  symbolTextSize: 12,
  symbolTextRadialOffset: 0,
  symbolTextColor: "#000000",
  symbolTextBackgroundColor: "rgba(0,0,0,0)",
  symbolTextOpacity: 1,
  symbolIconImage: "",
  symbolIconImageSize: 1,
  symbolIconImageOffset: [0, 0],
  symbolIconImageRotate: 0,
  symbolIconImageAnchor: "center",
  symbolIconImageColor: "#000000",
  symbolIconImageOpacity: 1,
  symbolZIndex: 1
})
const symbolLayer = new DiMap.SymbolLayer()
symbolFeature.addToLayer(symbolLayer)
symbolLayer.addToMap(map)

constructor

Parameters

参数名必选类型描述
optsSymbolFeatureOptions符号要素属性
userDataRecord<string, any>用户自定义数据,默认值为 {}

SymbolFeatureOptions

符号要素属性

Properties

参数名必选类型描述
geoData[number, number]空间数据,[经度, 纬度]
symbolTextContentstring文字内容
symbolTextAnchorAnchor文字角标位置
symbolTextSizenumber文字大小(pixels)
symbolTextRadialOffsetnumber文本偏移量(pixels),此值作用方向跟随 symbolTextAnchor
symbolTextColorstring文本颜色
symbolTextBackgroundColorstring文本背景颜色
symbolTextOpacitynumber文本透明度
symbolIconImagestring图标名称或 URL,如果是名称需要预先 addImage,URL 则内部处理
symbolIconImageSizenumber | [number, number]图标缩放比或 [width, height]
symbolIconImageRotatenumber图标旋转角度,范围 -360 到 360
symbolIconImageAnchorAnchor图标角标位置
symbolIconImageColorstring图标颜色,仅当image在addImage(name, img, { sdf: true })时生效
symbolIconImageOpacitynumber图标透明度
symbolZIndexnumber优先级