Skip to content

地图标记(MapMarker)

示例

示例源码
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

名称描述类型默认值
anchor表示标记的哪个部位距离坐标点最近string('center', 'top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right')bottom
color默认标记的颜色string#3FB1CE
coordinatesv-model marker的经纬度位置number[]-
draggable能否在地图拖拽booleantrue
offset偏移量 正数表示右/上number[][0, 0]

EVENTS

名称描述参数
created地图初始化完成事件-
update:coordinatesmarker位置更新事件number[]

SLOTS

名称描述
default默认插槽

METHODS

名称描述定义