如何解决getLocation定位偏差的问题?
发布于 6 年前 作者 guiyingpeng 11914 次浏览 来自 问答

在用getLocation的时候 ,获取经纬度。

1.同一位置。开发者工具上获取准确,在苹果手机端获取偏差一千米。

2.同一位置。开发者工具上获取相差几公里,在安卓手机上获取准确。

这是我和同事测试的时候 的情况。疫情期间不能出门,只能这么测试。请问各位大佬,会有哪些因素影响到getLocation定位精确度。

(补充一下,用高德的api也是一样的 问题 == )

            wx.getLocation({
        type"gcj02",
        success: res => {
          const lat = res.latitude;
          const lon = res.longitude;
        },
        fail: res => {
          //用户未授权小程序获取地理位置
          wx.showModal({
            content:
              "获取地理位置失败!\r\n请前往'设置'允许运管通\r\n使用您的地理位置",
            showCancel: true//是否显示取消按钮
            cancelText: "取消"//默认是“取消”
            cancelColor: "#3296fa"//取消文字的颜色
            confirmText: "设置"//默认是“确定”
            confirmColor: "#3296fa"//确定文字的颜色
            success: re => {
              wx.getSetting({
                success: resSetting => {
                  if (!resSetting.authSetting["scope.userLocation"]) {
                    wx.openSetting({
                      success: res => {
                      }
                    });
                  }
                }
              });
            }
          });
        }

1 回复

你好,小程序目前支持:

  1. getLocation接口高精度定位的能力https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getLocation.html;

2.持续定位的接口(精度会随着定位时间,越来越高)https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdateBackground.html

回到顶部