Skip to content

fpi-map 地图

TIP

  • 当前组件在 element-plus-expand
  • 需要引入 mapbox-gl-v22.css
    • <link rel="stylesheet" href="static/mapbox-gl-v22.css">
  • 需要引入 mapbox-gl-v22.js
    • <script src="static/mapbox-gl-v22.js" type="text/javascript"></script>
<template>
    <fpi-map
        :to-fixed-num="8"
        @selected-map="getAddress"
    />
    <div>
        经纬度:{{ location }}
    </div>
    <div style="text-indent: 16px;">
        地址:{{ address }}
    </div>
    <div style="text-indent: 16px;">
        区号:{{ adcode }}
    </div>
</template>

<script setup lang="ts">
import { reactive, toRefs } from 'vue'
const state = reactive({
    position: [], // 经度 纬度
    address: '', // 地址
    adcode: '', // 区号
    location: '', // 经纬度
})
/**
 * 获取点击地图的位置
 * @param data
 */
function getAddress(data: { adcode: string; address: string; location: string }) {
    state.address = data.address
    state.adcode = data.adcode
    state.location = data.location
}
const { position, address, adcode, location } = toRefs(state)
</script>
显示代码

属性

参数说明类型可选值默认值
isLook是否仅是查看boolean-false
isShowSearch是否显示搜索boolean-true
zoom地图 zoomnumber-12.5
centerPosition经纬度的值用于回显number[]-[120.193938105986, 30.190082529340692]
height经纬度的值用于回显string-320px
width经纬度的值用于回显string-100%
toFixedNum经纬度的值修约number-6

事件

事件名说明参数
selectedMap选择地图点位。当前选则的位置包括经纬度,地址,区号

fpi-component