绘制控件(DrawControl)
示例
示例源码
vue
<template>
<div style="height: 400px" class="vw-full vh-full">
<mb-map>
<mb-tianditu-layer />
<mb-draw-control position="top-right" />
</mb-map>
</div>
</template>
<script setup lang="ts"></script>API
PROPS
| 名称 | 描述 | 类型 | 默认值 |
|---|---|---|---|
| functions | 控件上呈现的功能 | array("point", "polyline", "polygon", "trash") | ["point", "polyline", "polygon", "trash"] |
| position | 控件所处位置 | string('top-left' , 'top-right' , 'bottom-left' ,'bottom-right') | top-right |
EVENTS
| 名称 | 描述 | 参数 |
|---|---|---|
| created | 地图初始化完成事件 | - |
| draw.created | 绘制完成事件 | features: AnyArr — 数组 |
| draw.delete | 删除元素事件 | features: AnyArr — 数组 |
| draw.update | 绘制元素更新事件 | object — 包含action属性与features |
SLOTS
| 名称 | 描述 |
|---|
METHODS
| 名称 | 描述 | 定义 |
|---|---|---|
| add | Returns: Array — featureIds | geojson: object — geojson对象 |
| get | Returns: object — feature geojson格式 | featureId: string |
| getSelectedIds | 获取被选中的元素id | () => array |
| getSelected | 获取被选中的元素 | () => object — geojson格式 featureCollection |
| getAll | 获取所有已绘制的元素 | () => object — geojson格式 featureCollection |
| delete | 根据id删除元素 | (ids: string[]) => void |
| deleteAll | 根据所有绘制的元素 | () => void |
