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 ​

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

SymbolFeatureOptions ​

符号要素属性

Properties ​

参数名必选类型描述
geoData是[number, number]空间数据,[经度, 纬度]
symbolTextContent是string文字内容
symbolTextAnchor否Anchor文字角标位置
symbolTextSize否number文字大小(pixels)
symbolTextRadialOffset否number文本偏移量(pixels),此值作用方向跟随 symbolTextAnchor
symbolTextColor否string文本颜色
symbolTextBackgroundColor否string文本背景颜色
symbolTextOpacity否number文本透明度
symbolIconImage否string图标名称或 URL,如果是名称需要预先 addImage,URL 则内部处理
symbolIconImageSize否number | [number, number]图标缩放比或 [width, height]
symbolIconImageRotate否number图标旋转角度,范围 -360 到 360
symbolIconImageAnchor否Anchor图标角标位置
symbolIconImageColor否string图标颜色,仅当image在addImage(name, img, { sdf: true })时生效
symbolIconImageOpacity否number图标透明度
symbolZIndex否number优先级