# 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 | 草图图形弧线类型 |
- SketchEditor#event:草图绘制完成事件
- SketchEditor#event:草图被选中事件
继承关系
- SketchEditor3D
成员变量
ArcType
# arcType
草图图形弧线类型。none不考虑弧度。geodesic大地线(或称为大圆线)。rhumb等角航线。目前绘制线、区、矩形时,该属性生效。
- Default Value:
- ArcType.rhumb
方法
# 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)
# 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)