Skip to content

YY. Style

样式类,为覆盖物的样式服务,主要用来生成覆盖物的样式配置对象, 一般我们使用其静态方法来生成 Style 对象

creation

  • constructor(options)
    • options {Object} 基本配置, 样式的配置
js
//一般我们使用其静态方法来生成 Style 对象
const style = new YY.Style({
    lineColor: "#fff"
});

example

js
//构造 图标样式  for YY.Point
YY.Style.formatImage({
    markerFile: "../assets/icons/5.png",
});

//构造矢量图形样式  YY.Point
YY.Style.formatGraphical({});

//构造图标和文本联合样式  for YY.Point
YY.Style.formatImageAndText({
    markerFile: "../assets/icons/6.png",
    textName: "hello",
});

//构造文本样式  for YY.Text
YY.Style.formatText({
    textName: "hello"
});

//构造线的样式  for YY.Polyline,YY.ArcCurve,YY.ConnectorLine,YY.ArcConnectorLine
YY.Style.formatLine({
    lineColor: "red"
});

//构造多边形样式,包括 YY.Polygon ,YY.Ellipse ,YY.Rectangle,YY.Circle ,YY.Sector
Style.formatFill();

method

TIP

static 表示静态方法, 即对象直接访问, 无需new

clone()

static formatImage(options)

js
YY.Style.formatImage({
    markerFile: "http://58.211.183.162:8941/yymap-examples-static/icons/0009.png",
    markerDy: 40,
    markerHeight: 70,
});

static formatText(options)

js
YY.Style.formatText({
    textName: "hello"
});

static formatImageAndText(options)

  • 构造图片和文字的样式配置
  • 参数
  • 返回值: YY. Style

static formatGraphical(options)

js
YY.Style.formatGraphical({
    markerWidth: 10,
    markerHeight: 10,
    markerType: "ellipse",
    markerFill: "red",
});

static formatGraphicalAndText(options)

  • 构造矢量图形和文字的样式配置
  • 参数
  • 返回值: YY. Style

static formatLine(options)

js
YY.Style.formatLine({
    lineColor: "red",
    lineWidth: 2,
});

static formatLineAndText(options)

  • 构造线路和线路文字的样式配置
  • 参数
  • 返回值: YY. Style

static formatFill(options)

js
YY.Style.formatFill({
    polygonFill: "red",
});

static formatFillAndText(options)

  • 构造多边形和文字的样式配置
  • 参数
  • 返回值: YY. Style

This document is generated by vitepress and Edit by deyihu