类名 DrawControl

# new DrawControl(options)

绘制工具

参数:

名称 类型 描述
options Object

构造参数

complete complete

绘制完成后的回调函数

查看源代码 Widget/Draw/DrawControl.js, line 10

示例

初始化绘制工具

// 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)

继承关系

方法

# destroy()

销毁控件

Inherited From:

查看源代码 Widget/Widget.js, line 38

# start(type, drawOptions)

开始绘制

参数:

名称 类型 描述
type String

绘制类型,lineString,polygon,rectangle,marker,circle

drawOptions

绘制参数

查看源代码 Widget/Draw/DrawControl.js, line 290

构造函数
成员变量
方法
事件