Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Shape

图形, 用作地图图形描述

Hierarchy

  • Shape

Index

Constructors

constructor

  • new Shape(data?: undefined | object, autoCalculateCentroid?: boolean): Shape
  • example
    // 将svg解析为Shape对象数组
    const shapes = await SvgUtils.parseSVG(
      <svg url>,
      [0.02, 0, 0, 0, 0, -0.02, 0, 0, 0, 0, 0, 0, -40, 40, 0, 1], // 对齐矩阵
    );
    // 也可以直接传入配置生成shape
    const shape = new Shape({ path: 'm0,0l1,0l1,1l0,1' }); // 正方形
    // 或
    shape.updateData({ fill: '#ff0000' });

    Parameters

    • Optional data: undefined | object

      基于ShapeData结构的描述.

    • Default value autoCalculateCentroid: boolean = true

      自动计算图形的视觉中心.

    Returns Shape

Properties

autoCalculateCentroid

autoCalculateCentroid: boolean

Methods

getData

  • 获得图形数据

    Returns ShapeData

getShapeType

  • getShapeType(): "point" | "line" | "shape"
  • 获得图形类型

    Returns "point" | "line" | "shape"

updateData

  • updateData(data: object, autoCalculateCentroid?: boolean): void
  • 更新图形数据

    Parameters

    • data: object

      基于ShapeData结构的描述

    • Default value autoCalculateCentroid: boolean = false

    Returns void

updatePathFromSelfSteps

  • updatePathFromSelfSteps(): void
  • Returns void