微信小程序---地图导航(点击地址,可以进行导航)

微信小程序—地图导航(点击地址,可以进行导航)

// 地图
  getLocation(e){
    var that = this,
    address = e.currentTarget.dataset.address;
    wx.getLocation({
      //定位类型 wgs84, gcj02
      type: 'gcj02',
      success: function(res) {
        console.log("定位信息", res);
        var url = 'https://apis.map.qq.com/ws/geocoder/v1/?address='+address+'&key=ssssssss';
        wx.request({
          url: url,
          success: function (res) {
            var location = res.data.result.location;
            wx.openLocation({
              address: address,
              name: address,
              longitude: +location.lng,
              latitude: +location.lat,
              scale: 18
            })
          }
        })
      },
    })
  },

你可能感兴趣的:(微信小程序,微信小程序,小程序,javascript)