类名 SketchEditor

# new SketchEditor(options)

Cesium引擎草图编辑类
继承自zondy.SketchEditor3D

[ES5引入方式]:
const { SketchEditor } = zondy.tool.sketch
[ES6引入方式]:
import { SketchEditor } from "@mapgis/webclient-leaflet-plugin"

参数:

名称 类型 默认值 描述
options Object

构造参数

view MapView | SceneView

地图视图对象

layer GraphicsLayer

草图图层管对象

sketchStyle SketchStyle

草图符号

snapOption Object

草图捕获配置项

arcType ArcType ArcType.rhumb

草图图形弧线类型
可选类型为:
1、ArcType.none:不考虑弧度
2、ArcType.geodesic:大地线(或称为大圆线)
3、ArcType.rhumb:等角航线
目前绘制线、区、矩形时,该属性生效
请注意当绘制几何的高程模式设置为OnTheGround(贴地)和OnTheScene(贴场景)时,arcType支持设置为ArcType.geodesic和ArcType.rhumb, 当设置为ArcType.none时,内部会将该属性设置为ArcType.geodesic *

  • SketchEditor#event:草图绘制完成事件
  • SketchEditor#event:草图被选中事件

继承关系

  • SketchEditor3D

成员变量

ArcType

# arcType

草图图形弧线类型。none不考虑弧度。geodesic大地线(或称为大圆线)。rhumb等角航线。目前绘制线、区、矩形时,该属性生效。

Default Value:
  • ArcType.rhumb

方法

# addVertex(point, index)

向当前线或区草图中插入新的顶点

参数:

名称 类型 描述
point Point

新增/插入顶点

index Number

新增/新增点的序号

改变后的图形几何

Geometry

# drawPolylineToPolygon(snapAndReferGeometries)

线拓扑造区

参数:

名称 类型 描述
snapAndReferGeometries Array.<Polygon>

捕获参考几何对象数组

示例

三维草图线拓扑造区

// [ES5引入方式]:
const { Polygon, LineString } = zondy.geometry
const { SceneView} = zondy.cesium
const { SketchEditor } = zondy.cesium.tool.sketch
[ES6引入方式]:
import { SceneView, SketchEditor } from "@mapgis/webclient-cesium-plugin" <br/>
import { Polygon, LineString } from "@mapgis/webclient-common" <br/>
var map = new Map()
var sceneView = new SceneView({
  viewId: "mapgis-3d-viewer",
  map: map,
})
var testGeometries = [
 new Polygon({
   coordinates: [
     [
       [114.0, 29.0],
       [117.0, 29.0],
       [117.0, 35.0],
       [114.0, 35.0],
       [114.0, 29.0]
     ]
   ]
 }),
 new Polygon({
   coordinates: [
     [
       [113.0, 29.0],
       [116.0, 29.0],
       [116.0, 35.0],
       [113.0, 35.0],
       [113.0, 29.0]
     ]
   ]
 })
]
testFeatures = [
new Feature({
    id: '11114',
    geometry: this.testGeometries[0],
    symbol: new SimpleFillSymbol({
      color: new Color(0, 255, 255, 0.5),
      outline: new SimpleLineSymbol({
        color: new Color(0, 255, 255, 0.8),
        width: 2
      })
    })
  }),
  new Feature({
    id: '11115',
    geometry: this.testGeometries[1],
    symbol: new SimpleFillSymbol({
      color: new Color(0, 255, 255, 0.5),
      outline: new SimpleLineSymbol({
        color: new Color(0, 255, 255, 0.8),
        width: 2
      })
    })
  }),
]
var testLayer = new GraphicsLayer({
   graphics: this.testFeatures
})
map.add(testLayer)
var sketchEditor = new SketchEditor({
  view: sceneView,
  layer: new GraphicsLayer()
})
sketchEditor.drawPolylineToPolygon(testGeometries)

# removeVertex(index)

移除草图图形的某个顶点

参数:

名称 类型 描述
index Number

需更新的顶点的序号

改变后的图形几何

Geometry

# split(target, splitPolyline)

分割草图对象或区几何对象

参数:

名称 类型 描述
target Polygon | SketchEditor

被分割的几何/草图对象

splitPolyline Polyline

线几何对象

分割后的几何对象

Array.<Polygon>
示例

三维草图几何分割

// [ES5引入方式]:
const { Polygon, LineString } = zondy.geometry
const { SceneView} = zondy.cesium
const { SketchEditor } = zondy.cesium.tool.sketch
[ES6引入方式]:
import { SceneView, SketchEditor } from "@mapgis/webclient-cesium-plugin" <br/>
import { Polygon, LineString } from "@mapgis/webclient-common" <br/>
var map = new Map()
var sceneView = new SceneView({
  viewId: "mapgis-3d-viewer",
  map: map,
})
var SketchEditor = new SketchEditor({
  view: sceneView,
  layer: new GraphicsLayer()
})
const polygon = new Polygon({
  coordinates: [
  [
      [108, 29],
      [116, 29],
      [116, 33],
      [108, 33],
      [108, 29]
    ]
  ]
})
const polyline = new LineString({
  coordinates: [
    [100, 30],
    [120, 30]
  ]
})
const newSketchEditors = SketchEditor.split(polygon,polyline)

# updateVertex(point, index)

更新当前选中或区草图图形的某个顶点

参数:

名称 类型 描述
point Point

新的顶点

index Number

需更新的顶点的序号

改变后的图形几何

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