收藏
回答

使用wx.onLocationChange 时,为什么位置没变 但会回调经纬度变化?

nLocation() {
    var that = this
    const _locationChangeFn = function(res) {
      console.log('location change', res)
      that.editSmallLocation(res.latitude, res.longitude)
     }
    wx.authorize({
      scope: 'scope.userLocationBackground',
      success: function (res) {
        wx.startLocationUpdateBackground({
          success: (res) => {
            console.log(res);
            wx.onLocationChange(_locationChangeFn)
          },
        })
      },
      fail: function (res) {
        console.log(res);
        wx.showModal({
          content: '获取后台定位权限失败,请前往设置打开"使用小程序和离开小程序后"',
          confirmText: '设置',
          success(res) {
            if (res.confirm) {
              wx.openSetting()
            } else if (res.cancel) {
              wx.onLocationChange(_locationChangeFn)
            }
          }
        })
      },
    })
},

这是wx.onLocationChange 返回的数据,手机一直没动,但是返回的经纬度有变化,打码的是相同的数据

最后一次编辑于  2021-08-08
回答关注问题邀请回答
收藏

3 个回答

  • 芬达
    芬达
    2022-10-13

    同样 手机没移动 经纬度自己变化

    2022-10-13
    有用
    回复
  • break
    break
    2021-08-16

    大佬,这个wx.onLocationChange,wx.offLocationChange是怎么使用的啊,我使用总是不对劲,一直获取定位停不下来。。

    2021-08-16
    有用
    回复
  • 安逸
    安逸
    2021-08-09

    很正常,手机定位不准确导致。

    2021-08-09
    有用
    回复 1
    • 山抹^微云~
      山抹^微云~
      2021-08-09
      所有的手机都会这样,波动范围有一公里
      2021-08-09
      回复
登录 后发表内容