使用的腾讯地图,配置的坐标系gcj02,同一个地理位置,使用api接口请求获取的经纬度和打包后的app获取的经纬度偏差距离很大。
1.api接口是直接在腾讯地图官网调用的获取地理位置解析的接口获取的;
2.app通过在项目manifest.json的“App模块配置”中勾选“Geolocation(定位)”,并根据项目实际需求勾选使用的腾讯地图定位SDK:配置的腾讯地图
3.uni-app获取定位方法
uni.getLocation({
type: 'gcj02',
geocode: true,
success: function(res) {
console.error(res)
_this.lat = res.latitude
_this.lng = res.longitude
let lat1 = res.latitude
let lng1 = res.longitude
let lat2 = _this.pharInfo.lat
let lng2 = _this.pharInfo.lng
console.log(lat1, lng1, lat2, lng2)
},
fail(err) {
console.log(err)
_this.showLocation = true
uni.showModal({
title: '定位失败,请先打开定位权限',
success(res) {
if (res.confirm) {
permission.gotoAppPermissionSetting()
}
}
})
},
complete(e) {
console.log(e)
}
});
4.api接口返回的地址位置信息图片1和app返回的坐标信息图片2,安卓内核版本4.19.191+