使用小程序getLocation获取到的经纬度偏差
发布于 5 年前 作者 gqiu 4984 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

门店的经纬度是高德的经纬度,获取到的经纬度拿到高德地图或者腾讯地图进行转换时和实际当前我的位置都是有偏差的,直线距离大概在五百米左右,通过地址搜索获取到的经纬度调用高德地图api,误差只有二十米左右

代码:

getMyLocation: function () {

/**获取位置信息 */

return new Promise((resolve, reject) => {

wx.getLocation({

success: (res) => { //

resolve(res);

this.setData({

getLocationFail: true

})

},

fail: (res) => { //拒绝授权

reject(res);

console.log('fail: ’ + res);

this.setData({

getLocationFail: false

})

}

})

})

},

pipeStoreInfo: function () {

/**获取附近所有门店 */

this.getMyLocation().then((res) => {

this.setData({

getLocationFail: true

})

this.getNearStore(res.latitude, res.longitude)

}, (res) => {

this.setData({

getLocationFail: false

})

})

},

4 回复

你的转换写法呢?

https://www.jianshu.com/p/9979f2a5ecaf 我不知道这种方式好不好用,你可以试一下,我的需求不是很大,没用过

整个应该很正常,跟设备还有环境都有很大的关系

正常,而且还不一定能实时刷新

回到顶部