Skip to content

MapPopup

Example

Example Source Code
vue
<template>
  <div style="height: 400px" class="vw-full vh-full">
    <mb-map :zoom="14" :pitch="40">
      <button
        class="primary"
        style="position: absolute; top: 5px; left: 5px"
        @click="
          ;(showCustomPopup = !showCustomPopup),
            (showDefaultPopup = !showDefaultPopup)
        "
      >
        Show/Hide Popup
      </button>
      <mb-tianditu-layer :types="['img']" />
      <mb-map-popup
        v-model:show="showCustomPopup"
        :coordinates="[116.388, 39.91266]"
        :offset="[0, -44]"
        :show-tip="false"
        anchor="bottom"
      >
        <div style="width: 100px; height: 100px; background: #81adb0d9">
          <p>Custom Popup</p>
        </div>
      </mb-map-popup>
      <mb-map-marker :coordinates="[116.388, 39.91266]" color="red" />

      <mb-map-popup
        v-model:show="showDefaultPopup"
        :coordinates="[116.4, 39.91266]"
        :hide-on-click="false"
      >
        <template #content> Default Popup </template>
      </mb-map-popup>
    </mb-map>
  </div>
</template>

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

const showCustomPopup = ref(true)
const showDefaultPopup = ref(true)
</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')-
class-nameClass added to the popup DOM elementstring-
coordinatesThe longitude and latitude position of the markernumber[]-
hide-on-clickWhether the popup automatically closes when the map is clickedbooleanfalse
hide-on-moveWhether the popup automatically closes when the mouse moves on the mapbooleanfalse
offsetThe popup offset. Positive values for right/downnumber / number[][0,0]
showv-model Whether the popup is visiblebooleantrue
show-tipWhether to automatically add a triangular tip to the popupbooleantrue
tip-colorThe color of the triangular tipstring#fff

EVENTS

NameDescriptionParameters
createdMap initialization completed event-
update:showShow/Hide eventshow: boolean

SLOTS

NameDescription
defaultDefault slot
contentContent slot

METHODS

NameDescriptionDefinition