1、逆地理位置编译(依据经纬度转换为地理位置信息)
第一步:先下载AMapWX
第二步:申请key(这里我直接备注了逆地理位置key)
第三步:依据经纬度,转换为实时的地理位置信息
import config from '@/utils/mapConfig'
import { AMapWX } from './amap-wx.130'
export default {
methods: {
// 调用
handleClick(e) {
this.handleAddressInfo(this.address.latitude, this.address.longitude)
},
// 转换
handleAddressInfo(latitude, longitude) {
var that = this
that.location = `${latitude},${longitude}`
const mt = new AMapWX({
// config.GD_ADDINFO_KEY,是我申请的逆地理位置key
key: config.GD_ADDINFO_KEY,
batch: true
})
mt.getRegeo({
location: that.location,
success: (res) => {
this.select_info = res[0].regeocodeData.formatted_address
},
fail: (error) => {
console.log('error', error)
}
})
}
}
}
补充:AMapWX代码(使用了export导出)