Summary
Methods:
activate |
激活标绘控件,只有将控件添加到地图上时才起作用。 |
deactivate |
禁用标绘控件。如果标绘尚未结束,则取消当前正在进行的绘制行为,然后禁用控件。 |
destroy |
销毁接口:销毁控件,释放占用的内存 |
enableEdit |
启用标绘控件的编辑功能 |
getControlType |
返回控件的类型 |
getId |
获取控件唯一标识 |
getLayer |
获取标绘控件的图层容器 |
getMap |
获取控件绑定的地图对象。 |
getStatus |
返回控件当前状态。 |
on |
绑定事件,同一个绘制对象的同种类型事件,多次绑定前面的将被覆盖。 |
removeEdit |
禁用标绘控件的编辑功能 |
setFeatureEdit |
设置指定要素为编辑状态 |
setId |
设置控件唯一标识。如果唯一标识已经存在,则会返回添加失败异常。 |
setNextFeatureStyle |
设置绘制样式 |
setPlotLayer |
设置标绘图层 |
setPlotType |
设置标绘类型。如果当前有正在进行的标绘行为,将被取消。 |
un |
取消事件绑定 |
Constructor
new Plot(options)
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | 必须项
|
Example
let plotControl = new hmap.control.Plot();
//事件回调枚举:
//plotEventType.NEWPOINT 绘制图形时,新增一个节点时触发
//plotEventType.CHANGEPOINT 绘制图形时,控制点随鼠标变化时触发
//plotEventType.PLOTFINISHED 单个图形绘制完成时触发
//plotEventType.EDITPOINT 编辑图形时,编辑单个节点时触发
//plotEventType.EDITMOVEEND 编辑图形时,移动一个要素或节点结束时触发
//plotEventType.EDITFINISHED 编辑图形时,完成单个编辑时触发
plotControl.on(plotControl.plotEventType.NEWPOINT,function(data){
console.log(data);
})
Methods
-
activate()
-
激活标绘控件,只有将控件添加到地图上时才起作用。
Example
plotControl.activate();
-
deactivate()
-
禁用标绘控件。如果标绘尚未结束,则取消当前正在进行的绘制行为,然后禁用控件。
Example
plotControl.deactivate();
-
destroy()
-
销毁接口:销毁控件,释放占用的内存
Example
pan.destroy();
-
enableEdit(editType)
-
启用标绘控件的编辑功能
Parameters:
Name Type Description editType
String 编辑类型,默认值为 空 ,要素和节点都可以编辑
Example
//参数枚举: //editType.FEATURE 只编辑要素(只拖动要素) //editType.POINT 只编辑节点(只拖动节点) plotControl.enableEdit(plotControl.editType.FEATURE)
-
getControlType() → {String}
-
返回控件的类型
Returns:
String -标绘控件类型的名称。
-
getId() → {String}
-
获取控件唯一标识
Returns:
String -控件标识。
-
getLayer() → {module:layer~VectorLayer}
-
获取标绘控件的图层容器
-
getMap() → {hmap.Map}
-
获取控件绑定的地图对象。
Returns:
hmap.Map -地图对象。
-
getStatus() → {Boolean}
-
返回控件当前状态。
Returns:
Boolean -true:表示激活 false:表示禁用。
-
on(type, callback)
-
绑定事件,同一个绘制对象的同种类型事件,多次绑定前面的将被覆盖。
Parameters:
Name Type Description type
String 触发类型 plotEventType的项
callback
function 回调函数
-
removeEdit()
-
禁用标绘控件的编辑功能
-
setFeatureEdit(feature)
-
设置指定要素为编辑状态
Parameters:
Name Type Description feature
module:feature~Vector 矢量要素
Example
polotControl.setFeatureEdit(feature);
-
setId(id)
-
设置控件唯一标识。如果唯一标识已经存在,则会返回添加失败异常。
Parameters:
Name Type Description id
String 控件唯一标识。
-
setNextFeatureStyle(style)
-
设置绘制样式
Parameters:
Name Type Description style
module:style~Style 绘制样式
-
setPlotLayer(layer)
-
设置标绘图层
Parameters:
Name Type Description layer
module:layer~VectorLayer 标绘图层
-
setPlotType(plotType)
-
设置标绘类型。如果当前有正在进行的标绘行为,将被取消。
Parameters:
Name Type Description plotType
String 设置绘制类型,参见PlotTypes枚举,如果设置undefined则停止绘制
-
un(type)
-
取消事件绑定
Parameters:
Name Type Description type
String 触发类型 plotEventType的项