类名 MapGISTextSymbol

# new MapGISTextSymbol(options)

文本符号,支持点几何对象,参考示例:[创建文本样式]

[ES5引入方式]:
zondy.symbol.MapGISTextSymbol()
[ES6引入方式]:
import { MapGISTextSymbol } from "@mapgis/webclient-common"

参数:

名称 类型 默认值 描述
options Object

构造参数

backgroundPadding Array.<Number> [5,5]

背景内边距

backgroundImage Image | function | undefined

背景图片样式,设置时会覆盖backgroundColor,在传入Image标签时,必须保证Image处理load完毕状态。传入函数时,按照canvas的绘制逻辑处理,第一个参数为ctx,第二个参数为绘制的width, 第三个参数为绘制的height

textDecorationUnderlineColor String

文字下划线颜色,计划废弃接口,推荐使用font属性中文字装饰元素属性decoration

textDecorationUnderlineWidth Number

文字下划线宽度,计划废弃接口,推荐使用font属性中文字装饰元素属性decoration

textDecorationThroughlineColor String

文字删除线颜色,计划废弃接口,推荐使用font属性中文字装饰元素属性decoration

textDecorationThroughlineWidth Number

文字删除线宽度,计划废弃接口,推荐使用font属性中文字装饰元素属性decoration

textShadowOffsetX Number 0

文字阴影横轴偏移

textShadowOffsetY Number 0

文字阴影纵轴偏移

textShadowBlur Number 1

文字阴影模糊度。一个非负浮点数,指定阴影模糊的级别,其中 0 表示没有模糊,数字越大表示模糊程度越高。这个值不对应于像素数量,并且不受当前变换矩阵的影响

textShadowColor String

文字阴影颜色

letterSpacing Number 0

文字间距

lineMaxNum Number 3

文字最大行数

textWraps Boolean false

是否换行

textExtraIcon Image

文字额外符号图标。测试接口,后续可能会改动。

textExtraIconAnchor String 'left'

文字额外图标方位,可选"left" "right" "top" "bottom"。测试接口,后续可能会改动。

textExtraIconSize Number 14

文字额外图标大小,单位像素。测试接口,后续可能会改动。

支持如下方法:
[1、将JSON里的数据导入,并返回一个新的TextSymbol对象]
[2、导出为JSON对象]
[3、克隆并返回新的符号对象]

示例

创建文本样式

// ES5引入方式
const { MapGISTextSymbol } = zondy.symbol
const { MapGISTextSymbol, Color } = zondy
// ES6引入方式
import { MapGISTextSymbol, Color } from "@mapgis/webclient-common"
const textSymbol = new MapGISTextSymbol({
  // 字体颜色
  color: new Color(252, 100, 22, 1),
  // 字体内容,如果是服务端数据,可不填
  text: "默认文字",
  // 字体样式
  font: {
    // 字体
    family: "微软雅黑",
    // 文字大小,单位像素
    size: 30,
    // 文字是否为斜体,正常模式
    style: "normal",
    // 文字粗细
    weight: "normal"
  }
})

继承关系

成员变量

Number

# angle

文字角度

Inherited From:
Color

# backgroundColor

文字背景颜色

Inherited From:
function | Image

# backgroundImage

文字背景颜色

Array.<Number>

# backgroundPadding

文字背景内边距

Color

# borderLineColor

文字外边框颜色

Inherited From:
Number

# borderLineSize

文字外边框线宽

Inherited From:
Color

# color

文字颜色

Inherited From:
Object

# extensionOptions

符号的额外构造参数,该构造参数是地图引擎的额外构造参数,在此设置了之后,会覆盖该符号转换好地图引擎的构造参数

Inherited From:
Default Value:
  • {}
Font

# font

文字字体

Inherited From:
Color

# haloColor

光晕颜色

Inherited From:
Number

# haloSize

光晕大小

Inherited From:
HorizontalAlignment

# horizontalAlignment

水平对齐

Inherited From:
String

# readonly id

符号id

Inherited From:
Boolean

# kerning

是否调整文本字符串中字符之间的间距

Inherited From:
Number

# letterSpacing

文字间距

Number

# lineHeight

行高,默认设置为1.1倍的字体size,表示上下文本间基线距离

Inherited From:
Number

# lineMaxNum

文字最大行数

Number

# lineWidth

行宽,单位为像素,默认是192px,超过这个长度会自动换行

Inherited From:
Boolean

# rotated

是否旋转

Inherited From:
String

# text

显示的内容

Inherited From:
Color

# textDecorationThroughlineColor

文字删除线颜色,计划废弃接口,推荐使用font属性中文字装饰元素属性decoration

Number

# textDecorationThroughlineWidth

文字删除线宽度,计划废弃接口,推荐使用font属性中文字装饰元素属性decoration

Color

# textDecorationUnderlineColor

文字下划线颜色,计划废弃接口,推荐使用font属性中文字装饰元素属性decoration

Number

# textDecorationUnderlineWidth

文字下划线宽度,计划废弃接口,推荐使用font属性中文字装饰元素属性decoration

Image

# textExtraIcon

注记额外符号

String

# textExtraIconAnchor

图标方位 "left" "right" "top" "bottom"

Number

# textExtraIconSize

图标大小

Number

# textShadowBlur

文字阴影模糊度。一个非负浮点数,指定阴影模糊的级别,其中 0 表示没有模糊,数字越大表示模糊程度越高。这个值不对应于像素数量,并且不受当前变换矩阵的影响

Color

# textShadowColor

文字阴影颜色

Number

# textShadowOffsetX

文字阴影横轴偏移

Number

# textShadowOffsetY

文字阴影纵轴偏移

Boolean

# textWraps

是否换行

String

# type

符号类型

Overrides:
VerticalAlignment

# verticalAlignment

垂直对齐

Inherited From:
Number

# xoffset

x偏移

Inherited From:
Number

# yoffset

y偏移

Inherited From:

方法

# static fromJSON(json)

参数:

名称 类型 描述
json Object

新的TextSymbol对象

新的TextSymbol对象

# clone()

Overrides:

克隆后的新符号对象

# toJSON()

Overrides:

JSON对像

Object
构造函数
成员变量
方法
事件