• 下载腾讯地图的js文件&获取腾讯地图Key
    • 应用在文件中

      1. let QQMapWx = require('../../../../utils/qqmap-wx-jssdk.min.js')
      2. let qqmapsdk = new QQMapWx({
      3. key: 'QZQBZ-L3GKW-RJRR3-RGUVB-5YKQK-M5FFO'
      4. })
    • 将函数封装在methods

    • 先获取我们的经纬度

      1. getLocation: function () {
      2. const that = this
      3. wx.getLocation({
      4. success(res) {
      5. const latitude = res.latitude
      6. const longitude = res.longitude
      7. that.getLocat(latitude,longitude)
      8. }
      9. })
      10. },
      11. // 成功后运行 腾讯地图的key
      12. getLocat:function(latitude,longitude){
      13. const that = this
      14. qqmapsdk.reverseGeocoder({
      15. location:{
      16. latitude: latitude,
      17. longitude: longitude
      18. },
      19. success:function(res){
      20. that.setData({WeiZhi : res.result.ad_info.city})
      21. },
      22. })
      23. },
      24. // 运行在
      25. onShow: function () {
      26. const vm = this
      27. vm.getLocation()
      28. }