- 下载腾讯地图的js文件&获取腾讯地图Key
应用在文件中
let QQMapWx = require('../../../../utils/qqmap-wx-jssdk.min.js')let qqmapsdk = new QQMapWx({key: 'QZQBZ-L3GKW-RJRR3-RGUVB-5YKQK-M5FFO'})
将函数封装在methods
先获取我们的经纬度
getLocation: function () {const that = thiswx.getLocation({success(res) {const latitude = res.latitudeconst longitude = res.longitudethat.getLocat(latitude,longitude)}})},// 成功后运行 腾讯地图的keygetLocat:function(latitude,longitude){const that = thisqqmapsdk.reverseGeocoder({location:{latitude: latitude,longitude: longitude},success:function(res){that.setData({WeiZhi : res.result.ad_info.city})},})},// 运行在onShow: function () {const vm = thisvm.getLocation()}
