小程序真机调试,wx.onLocationChange监听位置不准确,请问有什么解决方法?
在真机调试时,手机放着不动,经纬度也一直在变化,甚至前后偏移距离达到30~40米 getAuth(){
const that = this;
wx.getSetting({
success(res) {
console.log("get auth success: ", res);
// 如果没有拿到scope.userLocationBackground授权,提示
if (!res.authSetting['scope.userLocationBackground']) {
wx.authorize({
scope: 'scope.userLocationBackground',
success() {
// 用户已经同意,调用wx.startLocationUpdateBackground
wx.startLocationUpdateBackground({
success(res) {
// 成功开启后台定位, 调用实时位置变更
that.openLocaionListener()
},
fail(err) {
console.log("error001", err);
that.getLocationWithoutListener();
}
})
},
fail(err) {
console.log("error002", err);
that.getLocationWithoutListener();
},
})
} else {
// 已经拿到scope.userLocationBackground授权调用
wx.startLocationUpdateBackground({
success(res) {
// 成功开启后台定位,
that.openLocaionListener()
},
fail(err) {
console.log("startLocationUpdateBackground fail", err);
}
})
}
}
})
},
openLocaionListener: function(){
console.log("openLocaionListener");
wx.onLocationChange(this._locationChangeFn) // 开始监听位置变化
},