# new DrawControl(options)
绘制工具
参数:
名称 | 类型 | 描述 |
---|---|---|
options |
Object | 构造参数 |
complete |
complete | 绘制完成后的回调函数 |
示例
// ES5引入方式
const { Map, MapView } = Zondy
const { DrawControl } = Zondy.Widget
// ES6引入方式
import { Map, MapView, DrawControl } from "@mapgis/webclient-leaflet-plugin"
// 初始化图层管理容器
const map = new Map();
// 初始化地图视图对象
const mapView = new MapView({
// 视图id
viewId: "viewer-id",
// 图层管理容器
map: map
});
// 初始化绘制控件
const drawControl = new DrawControl({
view: mapView,
visible: true,
complete: function (type, feature) {
console.log("绘制类型:", type, ",绘制完成:", feature);
featureLayer.add(feature);
}
})
// 开始绘制
drawControl.start('lineString', {})
// ES5引入方式
const { Map, MapView } = Zondy
const { DrawControl } = Zondy.Widget
// ES6引入方式
import { Map, MapView, DrawControl } from "@mapgis/webclient-leaflet-plugin"
// 初始化图层管理容器
const map = new Map();
// 初始化地图视图对象
const mapView = new MapView({
// 视图id
viewId: "viewer-id",
// 图层管理容器
map: map
});
// 初始化绘制控件
const drawControl = new DrawControl({
view: mapView,
visible: true,
complete: function (type, feature) {
console.log("绘制类型:", type, ",绘制完成:", feature);
featureLayer.add(feature);
}
})
// 添加控件
mapView.ui.add(drawControl)
继承关系
方法
# start(type, drawOptions)
开始绘制
参数:
名称 | 类型 | 描述 |
---|---|---|
type |
String | 绘制类型,lineString,polygon,rectangle,marker,circle |
drawOptions |
绘制参数 |