Appearance
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 | 地图 zoom | number | - | 12.5 |
centerPosition | 经纬度的值用于回显 | number[] | - | [120.193938105986, 30.190082529340692] |
height | 经纬度的值用于回显 | string | - | 320px |
width | 经纬度的值用于回显 | string | - | 100% |
toFixedNum | 经纬度的值修约 | number | - | 6 |
事件
事件名 | 说明 | 参数 |
---|---|---|
selectedMap | 选择地图点位。 | 当前选则的位置包括经纬度,地址,区号 |