Class: SketchEditor

SketchEditor

new SketchEditor(options)

sketchEditor/SketchEditor.js, line 15

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

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

Name Type Description
options Object

构造参数

Name Type Default Description
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 *

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

Extends

  • SketchEditor3D

Members

arcTypeArcType

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

Default Value:
ArcType.rhumb

Methods

addVertex(point, index){Geometry}

sketchEditor/SketchEditor.js, line 59

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

Name Type Description
point Point

新增/插入顶点

index Number

新增点的索引值,索引值从0开始

Returns:
Type Description
Geometry 改变后的图形几何

drawPolylineToPolygon(snapAndReferGeometries)

sketchEditor/SketchEditor.js, line 210

线拓扑造区

Name Type Description
snapAndReferGeometries Array.<Polygon>

捕获参考几何对象数组

Example

三维草图线拓扑造区

// [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" 
import { Polygon, LineString } from "@mapgis/webclient-common"
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){Geometry}

sketchEditor/SketchEditor.js, line 86

移除草图图形的某个顶点

Name Type Description
index Number

需移除的顶点的索引值,索引值从0开始

Returns:
Type Description
Geometry 改变后的图形几何

split(target, splitPolyline){Array.<Polygon>}

sketchEditor/SketchEditor.js, line 132

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

Name Type Description
target Polygon | SketchEditor

被分割的几何/草图对象

splitPolyline Polyline

线几何对象

Returns:
Type Description
Array.<Polygon> 分割后的几何对象
Example

三维草图几何分割

// [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" 
import { Polygon, LineString } from "@mapgis/webclient-common"
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){Geometry}

sketchEditor/SketchEditor.js, line 73

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

Name Type Description
point Point

新的顶点

index Number

需更新的顶点的索引值,索引值从0开始

Returns:
Type Description
Geometry 改变后的图形几何