Skip to content

MapMarker

Example

Example Source Code
vue
<template>
  <div style="height: 400px" class="vw-full vh-full">
    <mb-map :zoom="14">
      <mb-tianditu-layer />
      <mb-map-marker
        v-model:coordinates="defaultMarkerCoordinates"
        color="red"
      />
      <mb-map-marker v-model:coordinates="customMarkerCoordinates">
        <button class="primary">按钮</button>
      </mb-map-marker>
      <mb-map-marker v-model:coordinates="customMarkerCoordinates2">
        <img
          src="https://cdn.pixabay.com/animation/2022/10/11/23/03/23-03-06-809_512.gif"
          style="width: 64px; height: 64px"
        />
      </mb-map-marker>
      <mb-map-marker v-model:coordinates="customMarkerCoordinates3">
        <Test1 />
      </mb-map-marker>
    </mb-map>
  </div>
</template>

<script setup lang="ts">
import { h, ref } from 'vue'

const Test1 = {
  setup() {
    return () =>
      h('div', {
        innerHTML: 'Vue Comp',
        style: { color: 'red', fontSize: '20px', fontWeight: 'bolder' },
      })
  },
}

const defaultMarkerCoordinates = ref([116.38745, 39.91266])
const customMarkerCoordinates = ref([116.40123, 39.91266])
const customMarkerCoordinates2 = ref([116.39123, 39.91266])
const customMarkerCoordinates3 = ref([116.38123, 39.91266])
</script>

API

PROPS

NameDescriptionTypeDefault
anchorSpecifies which part of the marker is closest to the coordinate pointstring('center', 'top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right')bottom
colorDefault color of the markerstring#3FB1CE
coordinatesv-model The longitude and latitude position of the markernumber[]-
draggableWhether the marker can be dragged on the mapbooleantrue
offsetOffset. Positive values indicate right/upnumber[][0, 0]

EVENTS

NameDescriptionParameters
createdMap initialization completed event-
update:coordinatesMarker position update eventnumber[]

SLOTS

NameDescription
defaultDefault slot

METHODS

NameDescriptionDefinition