小程序通过坐标请求腾讯位置服务获取当前位置信息

时间:2020-06-13 12:55:38   收藏:0   阅读:97
 getLocal(){
    let that=this;
    wx.getLocation({
      type: ‘gcj02‘,
      success(res) {
        const latitude = res.latitude
        const longitude = res.longitude
        console.log(latitude)
        console.log(longitude)
       that.getLocalMess(latitude,longitude)
      }
    })
  },
  getLocalMess(lat,lon){
    var _this = this;
    qqmapsdk.reverseGeocoder({
      //位置坐标,默认获取当前位置,非必须参数
      location: {
        latitude: lat,
        longitude: lon
      },
      success: function(res) {//成功后的回调
        console.log(res);
      },
      fail: function(error) {
        console.error(error);
      },
      complete: function(res) {
        console.log(res);
      }
    })
  },

 

原文:https://www.cnblogs.com/dianzan/p/13113467.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!