var QQMapWX = require('qqmap-wx-jssdk') var qqmapsdk = new QQMapWX({ key: '填写你的key' // 必填 }) wx.getLocation({ type: 'wgs84', success (res) { console.log('纬度', res.latitude, '经度', res.longitude) wx.setStorageSync('latitude', res.latitude) wx.setStorageSync('longitude', res.longitude) }, //wx.getLocation 回调里面把上面获取到的经纬度给引入的qqmap-wx-jssdk就能够获取到对应的地点了 complete () { // 坐标转换 qqmapsdk.reverseGeocoder({ // 位置坐标,默认获取当前位置,非必须参数 location: { latitude: wx.getStorageSync('latitude'), longitude: wx.getStorageSync('longitude') }, success: function (res) { console.log(res.result.address_component.city) wx.setStorageSync('address_component', res.result.address_component.city) }, fail: function (error) { console.error('错误', error) } }) } })