# Class: SketchEditor

## SketchEditor()

#### new SketchEditor()

草图编辑器

Source:
  - SketchEditor.js, line 39

### Methods

#### (async, static) addStateChangedListener() → {Promise.<Void>}

添加状态改变监听

Source:
  - SketchEditor.js, line 72

##### Returns:

Type
  Promise.<Void>

#### (async, static) addVertex(x坐标的值, y坐标的值) → {Promise.<Void>}

添加新的顶点（地图坐标）

##### Parameters:

Name | Type | Description
--- | --- | ---
`x坐标的值` | Number |
`y坐标的值` | Number |

Source:
  - SketchEditor.js, line 309

##### Returns:

Type
  Promise.<Void>

#### (async, static) clearGeometry() → {Promise.<Void>}

清除当前的编辑几何

Source:
  - SketchEditor.js, line 251

##### Returns:

Type
  Promise.<Void>

#### (async, static) createObj(mapView) → {Promise.<SketchEditor>}

构造一个新的SketchEditor对象

##### Parameters:

Name | Type | Description
--- | --- | ---
`mapView` | Object | 地图视图对象

Source:
  - SketchEditor.js, line 51

##### Returns:

Type
  Promise.<SketchEditor>

#### (async, static) deleteSelectedVertex() → {boolean}

删除当前被选中的顶点

Source:
  - SketchEditor.js, line 277

##### Returns:

Type
  boolean

#### (async, static) getGeometry() → {Promise.<Geometry>}

获取当前的编辑几何

Source:
  - SketchEditor.js, line 230

##### Returns:

成功返回几何对象

Type
  Promise.<Geometry>

#### (async, static) getMeasureOption() → {Promise.<MeasureOption>}

获取量算参数选项

Source:
  - SketchEditor.js, line 462

##### Returns:

Type
  Promise.<MeasureOption>

#### (async, static) getSketchDataType() → {Number}

获取编辑的数据类型

Source:
  - SketchEditor.js, line 202

##### Returns:

几何类型（int类型的Number，例:1--SketchDataType.POINT，-1表示获取失败）

Type
  Number

#### (async, static) getSketchStyle() → {Promise.<SketchStyle>}

获取草图样式

Source:
  - SketchEditor.js, line 99

##### Returns:

Type
  Promise.<SketchStyle>

#### (async, static) getSnappingOption() → {Promise.<SnappingOption>}

获取捕捉选项

Source:
  - SketchEditor.js, line 136

##### Returns:

Type
  Promise.<SnappingOption>

#### (async, static) getSRS() → {Promise.<SRefData>}

获取空间参考系

Source:
  - SketchEditor.js, line 421

##### Returns:

Type
  Promise.<SRefData>

#### (async, static) isSketchValid() → {boolean}

草图几何是否有效（点几何必须有1个顶点、线必须有2个顶点、区必须有3个顶点）

Source:
  - SketchEditor.js, line 374

##### Returns:

Type
  boolean

#### (async, static) moveSelectedVertexTo(x坐标的值, y坐标的值) → {boolean}

移动当前被选中的顶点到指定的位置（地图坐标）

##### Parameters:

Name | Type | Description
--- | --- | ---
`x坐标的值` | Number |
`y坐标的值` | Number |

Source:
  - SketchEditor.js, line 293

##### Returns:

Type
  boolean

#### (async, static) redo() → {boolean}

重做

Source:
  - SketchEditor.js, line 359

##### Returns:

true-成功；false-失败

Type
  boolean

#### (async, static) removeStateChangedListener() → {Promise.<Void>}

移除状态改变监听

Source:
  - SketchEditor.js, line 86

##### Returns:

Type
  Promise.<Void>

#### (async, static) replaceGeometry(geometry) → {Promise.<Void>}

替换当前的编辑几何对象

##### Parameters:

Name | Type | Description
--- | --- | ---
`geometry` | Object | 几何对象

Source:
  - SketchEditor.js, line 217

##### Returns:

Type
  Promise.<Void>

#### (async, static) setMagnifierOption(magnifierOption) → {Promise.<Void>}

设置地图位置组件

##### Parameters:

Name | Type | Description
--- | --- | ---
`magnifierOption` | Object | 地图位置组件

Source:
  - SketchEditor.js, line 391

##### Returns:

Type
  Promise.<Void>

#### (async, static) setMeasureOption(measureOption) → {Promise.<Void>}

设置量算参数选项

##### Parameters:

Name | Type | Description
--- | --- | ---
`measureOption` | MeasureOption | 量算参数选项

Source:
  - SketchEditor.js, line 443

##### Returns:

Type
  Promise.<Void>

#### (async, static) setSketchStyle(sketchStyle) → {Promise.<Void>}

设置草图样式

##### Parameters:

Name | Type | Description
--- | --- | ---
`sketchStyle` | Object | 草图样式(SketchStyle类型的Object)

Source:
  - SketchEditor.js, line 120

##### Returns:

Type
  Promise.<Void>

#### (async, static) setSnappingOption(snappingOption) → {Promise.<Void>}

设置捕捉选项

##### Parameters:

Name | Type | Description
--- | --- | ---
`snappingOption` | Object | 捕捉选项(SnappingOption类型的Object)

Source:
  - SketchEditor.js, line 158

##### Returns:

Type
  Promise.<Void>

#### (async, static) setSRS(空间参考系) → {Promise.<Void>}

设置编辑数据的空间参考系，用于计算实地距离和面积

##### Parameters:

Name | Type | Description
--- | --- | ---
`空间参考系` | SRefData |

Source:
  - SketchEditor.js, line 408

##### Returns:

Type
  Promise.<Void>

#### (async, static) snapping(x坐标的值, y坐标的值) → {Promise.<Dot>}

试图捕捉指定点（地图坐标，返回被捕捉到的点，返回null表示捕捉失败

##### Parameters:

Name | Type | Description
--- | --- | ---
`x坐标的值` | Number |
`y坐标的值` | Number |

Source:
  - SketchEditor.js, line 324

##### Returns:

返回null表示捕捉失败

Type
  Promise.<Dot>

#### (async, static) start(geometry) → {Promise.<Void>}

开始编辑已有的几何对象

##### Parameters:

Name | Type | Description
--- | --- | ---
`geometry` | Object | 几何对象

Source:
  - SketchEditor.js, line 189

##### Returns:

Type
  Promise.<Void>

#### (async, static) startByType(sketchDataType) → {Promise.<Void>}

依据指定的数据类型开始新的几何编辑

##### Parameters:

Name | Type | Description
--- | --- | ---
`sketchDataType` | Number | 几何类型（int类型的Number，例:1--SketchDataType.POINT）

Source:
  - SketchEditor.js, line 175

##### Returns:

Type
  Promise.<Void>

#### (async, static) stop() → {Promise.<Void>}

停止编辑

Source:
  - SketchEditor.js, line 264

##### Returns:

Type
  Promise.<Void>

#### (async, static) undo() → {boolean}

撤销

Source:
  - SketchEditor.js, line 344

##### Returns:

true-成功；false-失败

Type
  boolean