引入模塊
npm i @amap/amap-jsapi-loader --save-dev
引入組件
import AMapLoader from '@amap/amap-jsapi-loader'
模塊初始化
initMap(lnglat) {
AMapLoader.load({
key: '你的密鑰', // 申請好的Web端開發者Key,首次呼叫 load 時必填
version: '1.4.8', // 指定要加載的 JSAPI 的版本,預設時默認為 1.4.15
plugins: ['AMap.Geocoder', 'AMap.Geolocation'] //插件串列
})
.then(AMap => {
this.AMapGetAddress(lnglat)
})
.catch(e => {
console.log(e)
})
},
呼叫逆決議地址
AMapGetAddress(lnglat = [120.187514, 30.250183]) {
// debugger
const geocoder = new AMap.Geocoder()
let that = this
geocoder.getAddress(lnglat, function (status, result) {
if (status === 'complete' && result.regeocode) {
console.log(result.regeocode.addressComponent.city)
that.getStationIp(result.regeocode.addressComponent.city)
} else {
log.error('根據經緯度查詢地址失敗')
}
})
},
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/287447.html
標籤:區塊鏈
上一篇:第76篇 Faucet 智能合約
