wx.getLocation位置不准确?
发布于 6 年前 作者 leijia 12727 次浏览 来自 问答

开启了高精度,拿到坐标还是不准确。

onShow: function () {
    var that = this
    wx.getLocation({
      isHighAccuracytrue,
      type'wgs84',
      success(loc){
        console.log(loc)
        that.setData({
          position_lat:loc.latitude,
          position_lng:loc.longitude
        })
      },
      fail(res){
        console.log('fail',res)
      },
      complete(res){
        console.log('comp',res)
      }
    })
  }
2 回复

gcj02 返回可用于 wx.openLocation 的坐标, 是不是type填错了

需要写上这个参数highAccuracyExpireTime,文档中说高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果

请看一下这个api【wx.getLocation】的具体参数,仔细阅读里面的参数和含义

api链接:https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getLocation.html


回到顶部