# new TextSymbol(options)
文本符号,支持点几何对象,参考示例:[创建文本样式]
[ES5引入方式]:
Zondy.Symbol.TextSymbol()
[ES6引入方式]:
import { TextSymbol } from "@mapgis/webclient-common"
参数:
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
options |
Object | 构造参数 |
|
color |
String | New Zondy.Color(0,0,0) | 颜色 |
font |
Font | 字体样式 |
|
horizontalAlignment |
HorizontalAlignment | 'center' | 水平方向,可选"left"|"right"|"center" |
lineHeight |
Number | 1.1 | 行高,最小设置为1.1 |
text |
String | 默认显示内容 |
|
verticalAlignment |
VerticalAlignment | 'baseline' | 垂直对齐,可选"baseline"|"top"|"middle"|"bottom" |
xoffset |
Number | 0 | x偏移 |
yoffset |
Number | 0 | y偏移 |
支持如下方法:
1、克隆并返回新的符号对象
2、导出一个JSON对像
[3、将JSON里的数据导入,并返回一个新的TextSymbol对象]
示例
// ES5引入方式
const { TextSymbol } = Zondy.Symbol
const { TextSymbol, Color } = Zondy
// ES6引入方式
import { TextSymbol, Color } from "@mapgis/webclient-common"
const textSymbol = new TextSymbol({
// 字体颜色
color: new Color(252, 100, 22, 1),
// 字体内容,如果是服务端数据,可不填
text: "默认文字",
// 字体样式
font: {
// 字体
family: "微软雅黑",
// 文字大小,单位像素
size: 30,
// 文字是否为斜体,正常模式
style: "normal",
// 文字粗细
weight: "normal"
}
})