收藏
回答

getLocation和onLocationChange定位,前后几秒存在500米误差?

-【公司的同事也复现了这个问题,我们可以上传今天的调用日志协助API开发者排查问题】

- 以下是API的主要调用方式:
  wx.getLocation({
    type: 'gcj02',
    success: res => {},
    fail: res => {}
  })

  wx.startLocationUpdate()
  wx.onLocationChange(res => {})

-以下是线上用户的日志(getLocation和onLocationChange的返回记录,分别在两个数组里,有时间戳):
    "onLocationChangeLogStack": [
      {
        "log": "第0项日志",
        "logContent": {
          "altitude": 0,
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.273546549479168,
          "accuracy": 30,
          "horizontalAccuracy": 30,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98670762803819,
          "direction": 0
        },
        "timestamp": 1640912040378
      },
      {
        "log": "onLocationChange_success",
        "logContent": {
          "altitude": 0,
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.275212944878472,
          "accuracy": 30,
          "horizontalAccuracy": 30,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98674289279514,
          "direction": 0
        },
        "timestamp": 1640912041363,
        "time": "08:54:01"
      },
      {
        "log": "onLocationChange_success",
        "logContent": {
          "altitude": 28.595458984375,
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "gps",
          "latitude": 30.275257161458335,
          "accuracy": 15.087242126464844,
          "horizontalAccuracy": 15.087242126464844,
          "type": "gcj02",
          "steps": 0,
          "speed": 0.9399999976158142,
          "longitude": 119.98688123914931,
          "direction": 49.5
        },
        "timestamp": 1640912043312,
        "time": "08:54:03"
      },
      {
        "log": "onLocationChange_success",
        "logContent": {
          "altitude": 26.94659423828125,
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "gps",
          "latitude": 30.27526611328125,
          "accuracy": 19.00754165649414,
          "horizontalAccuracy": 19.00754165649414,
          "type": "gcj02",
          "steps": 0,
          "speed": 0.9399999976158142,
          "longitude": 119.98689208984375,
          "direction": 49.5
        },
        "timestamp": 1640912044285,
        "time": "08:54:04"
      },
      {
        "log": "onLocationChange_success",
        "logContent": {
          "altitude": 0,
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.274973415798613,
          "accuracy": 30,
          "horizontalAccuracy": 30,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98738661024305,
          "direction": 0
        },
        "timestamp": 1640912279392,
        "time": "08:57:59"
      },
      {
        "log": "onLocationChange_success",
        "logContent": {
          "altitude": 0,
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.274985894097224,
          "accuracy": 30,
          "horizontalAccuracy": 30,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98747043185764,
          "direction": 0
        },
        "timestamp": 1640912281414,
        "time": "08:58:01"
      },
      {
        "log": "onLocationChange_success",
        "logContent": {
          "altitude": 0,
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.274640028211806,
          "accuracy": 15,
          "horizontalAccuracy": 15,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98615234375,
          "direction": 0
        },
        "timestamp": 1640912606404,
        "time": "09:03:26"
      },
      {
        "logContent": "___same___",
        "timestamp": 1640912614404,
        "time": "09:03:34"
      },
      {
        "logContent": "___same___",
        "timestamp": 1640912622407,
        "time": "09:03:42"
      },
      {
        "logContent": "___same___",
        "timestamp": 1640912632259,
        "time": "09:03:52"
      },
      {
        "logContent": "___same___",
        "timestamp": 1640912647807,
        "time": "09:04:07"
      },
      {
        "log": "onLocationChange_success",
        "logContent": {
          "altitude": 0,
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.27372802734375,
          "accuracy": 306,
          "horizontalAccuracy": 306,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98235324435764,
          "direction": 0
        },
        "timestamp": 1640913353009,
        "time": "09:15:53"
      },
      {
        "log": "onLocationChange_success",
        "logContent": {
          "altitude": 0,
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.273546549479168,
          "accuracy": 30,
          "horizontalAccuracy": 30,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98670762803819,
          "direction": 0
        },
        "timestamp": 1640913355016,
        "time": "09:15:55"
      },
      {
        "logContent": "___same___",
        "timestamp": 1640913363595,
        "time": "09:16:03"
      }
    ],


    "getLocationLogStack": [
      {
        "log": "第0项日志",
        "logContent": {
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.273546549479168,
          "errMsg": "getLocation:ok",
          "accuracy": 30,
          "horizontalAccuracy": 30,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98670762803819,
          "direction": 0
        },
        "timestamp": 1640912040378
      },
      {
        "log": "getLocation_success",
        "logContent": {
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.275212944878472,
          "errMsg": "getLocation:ok",
          "accuracy": 30,
          "horizontalAccuracy": 30,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98674289279514,
          "direction": 0
        },
        "timestamp": 1640912041965,
        "time": "08:54:01"
      },
      {
        "log": "getLocation_success",
        "logContent": {
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.274973415798613,
          "errMsg": "getLocation:ok",
          "accuracy": 30,
          "horizontalAccuracy": 30,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98738661024305,
          "direction": 0
        },
        "timestamp": 1640912279687,
        "time": "08:57:59"
      },
      {
        "log": "getLocation_success",
        "logContent": {
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.274640028211806,
          "errMsg": "getLocation:ok",
          "accuracy": 15,
          "horizontalAccuracy": 15,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98615234375,
          "direction": 0
        },
        "timestamp": 1640912606596,
        "time": "09:03:26"
      },
      {
        "logContent": "___same___",
        "timestamp": 1640912616342,
        "time": "09:03:36"
      },
      {
        "logContent": "___same___",
        "timestamp": 1640912625900,
        "time": "09:03:45"
      },
      {
        "logContent": "___same___",
        "timestamp": 1640912635401,
        "time": "09:03:55"
      },
      {
        "logContent": "___same___",
        "timestamp": 1640912647918,
        "time": "09:04:07"
      },
      {
        "log": "getLocation_success",
        "logContent": {
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.27372802734375,
          "errMsg": "getLocation:ok",
          "accuracy": 306,
          "horizontalAccuracy": 306,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98235324435764,
          "direction": 0
        },
        "timestamp": 1640913353298,
        "time": "09:15:53"
      },
      {
        "log": "getLocation_success",
        "logContent": {
          "verticalAccuracy": 0,
          "indoorLocationType": -1,
          "provider": "network",
          "latitude": 30.273546549479168,
          "errMsg": "getLocation:ok",
          "accuracy": 30,
          "horizontalAccuracy": 30,
          "type": "gcj02",
          "steps": 0,
          "speed": 0,
          "longitude": 119.98670762803819,
          "direction": 0
        },
        "timestamp": 1640913363578,
        "time": "09:16:03"
      }
  • ],
最后一次编辑于  2021-12-31
回答关注问题邀请回答
收藏

4 个回答

  • 疯狂的石头
    疯狂的石头
    2022-05-24

    居然今天还没结论

    2022-05-24
    有用
    回复
  • Cjiang
    Cjiang
    2021-12-31

    你好,麻烦在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点(具体到分钟)

    2021-12-31
    有用
    回复 4
    • 青团社
      青团社
      2022-01-04
      好的,微信日志已上传。
      wx号:YEZHUPEIJI
      时间 2021/12/31 09:15:55前后
      2022-01-04
      回复
    • Cjiang
      Cjiang
      2022-01-05回复青团社
      安卓还是ios的问题呢?
      2022-01-05
      回复
    • 青团社
      青团社
      2022-01-05回复Cjiang
      上传日志的是安卓的
      2022-01-05
      回复
    • 青团社
      青团社
      2022-01-05回复Cjiang
      Android 11
      brand:Redmi,
      model:M2012K11AC,
      weChatVersion:8.0.16,
      SDKVersion:2.21.2
      2022-01-05
      回复
  • 微喵网络
    微喵网络
    2021-12-31

    不是因为坐标系不同?

    2021-12-31
    有用
    回复
  • 青团社
    青团社
    2021-12-31
    从日志可以看出:
    09:15:53 的经纬度为:119.98235324435764,30.27372802734375
    
    09:15:55 的经纬度就成了:119.98670762803819,30.273546549479168
    
    大约偏差了400多米
    
    线上多个用户的日志分析结果也会如此,一般是500左右的误差
    
    
    
    2021-12-31
    有用
    回复 2
    • 共济同舟
      共济同舟
      2022-08-09
      这只偏了400米啊,我们设置1000米的半径都不行
      2022-08-09
      回复
    • 青团社
      青团社
      2022-08-26回复共济同舟
      那你们是不是用的火星坐标系。用gcj02的试试。
      2022-08-26
      回复
登录 后发表内容