Skip to content

DrawControl

Example

Example Source Code
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

NameDescriptionTypeDefault
functionsFunctionsarray("point", "polyline", "polygon", "trash")["point", "polyline", "polygon", "trash"]
positionPositionstring('top-left' , 'top-right' , 'bottom-left' ,'bottom-right')top-right

EVENTS

NameDescriptionParameters
createdMap initialization completed event-
draw.createdDrawing completed eventfeatures: AnyArr
draw.deleteDelete element(s) eventfeatures: AnyArr
draw.updateDrawing element(s) updated eventobject — Contains action property and features

SLOTS

NameDescription

METHODS

NameDescriptionDefinition
addReturns: Array — featureIdsgeojson: object — geojson
getReturns: object — feature geojsonfeatureId: string
getSelectedIdsGets the IDs of the currently selected features() => string[]
getSelectedGets the currently selected features in GeoJSON format (as a FeatureCollection)() => object — featureCollection
getAllGets all drawn features in GeoJSON format (as a FeatureCollection)() => object — geojson featureCollection
deleteDeletes features based on their IDs(ids: string[]) => void
deleteAllDeletes all drawn features() => void