腾讯地图经纬度解析出地址
生活随笔
收集整理的這篇文章主要介紹了
腾讯地图经纬度解析出地址
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
先封裝好,在到頁面中引用,到騰訊地圖的開發(fā)者里面可以配置,能拿到key的值
//騰訊地圖接口,逆解析地址 export default function(longitude, latitude) {return new Promise((resolve, reject) => {//小程序請求封裝,可以自己改動wx.request({url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + latitude + ',' + longitude +'&key=騰訊地圖里面有key的值',method: 'GET',success: (res) => {if (res.statusCode === 200) {resolve(res.data)}}})}) }在代碼中引用進(jìn)來
// 導(dǎo)入進(jìn)來 import txGetAddress from 'api/map.js' //逆解析地址getLocation() {//獲取地址授權(quán),拿到經(jīng)緯度wx.getLocation({type: 'wgs84',altitude: true,success: (res) => {//逆解析地址,拿到最終地址txGetAddress(res.longitude, res.latitude).then(res => {//城市地址this.city = res.result.address_component.city})}}) },希望可以幫助到大家
總結(jié)
以上是生活随笔為你收集整理的腾讯地图经纬度解析出地址的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VS2008配置directx8
- 下一篇: mdb access2000 中文密码破