uni.getLocation({
type: 'wgs84',
geocode:true,
success: res => {
console.log(res.address.city);
this.city = res.address.city;
this.queryHospital({city: res.address.city});
},
fail: (e) => {
uni.hideLoading();
this.ent.toast("定位失败");
}
});

- 发布:2021-01-27 09:59
- 更新:2022-12-16 10:36
- 阅读:1065
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 10.14.6
HBuilderX类型: 正式
HBuilderX版本号: 2.9.8
手机系统: iOS
手机系统版本号: IOS 14
手机厂商: 苹果
手机机型: iPhone XS Max
页面类型: vue
nvue编译模式: fast
打包方式: 离线
项目创建方式: HBuilderX
示例代码:
操作步骤:
直接页面中请求
uni.getLocation({
type: 'wgs84',
geocode:true,
success: res => {
console.log(res.address.city);
this.city = res.address.city;
this.queryHospital({city: res.address.city});
},
fail: (e) => {
uni.hideLoading();
this.ent.toast("定位失败");
}
});
直接页面中请求
uni.getLocation({
type: 'wgs84',
geocode:true,
success: res => {
console.log(res.address.city);
this.city = res.address.city;
this.queryHospital({city: res.address.city});
},
fail: (e) => {
uni.hideLoading();
this.ent.toast("定位失败");
}
});
预期结果:
走定位成功回调
走定位成功回调
实际结果:
走了fail定位失败回调
走了fail定位失败回调
bug描述:
uni.getLocation 在ios 14.1上面没有问题,在ios 14.2及以上 都会有问题,走了fail 回调,授权页面出来了点击同意授权以后,走了fail失败回调,要么一直定位中没有任何返回
8 个回复
rok138
我也是,uni.getLocation安卓正常,ios一直fail提示errMsg: "getLocation:fail system permission denied"
uni.getLocation({
type: 'gcj02',
success: res=> {
console.log("getLocation res#:",res)
resolve({
longitude: res.longitude,
latitude: res.latitude
})
},
fail: err=> {
console.log("err#1 getLocation",err)
resolve({
longitude: 118.59716,
latitude: 24.883448,
})
},
complete(res) {
console.log(res);
}
})
3***@qq.com
我也是
涂涛
请问解决了吗?
l***@163.com
请问有人解决了吗?在真机模拟上可以 但是只要是打包app出来 ios中都定位不了 都是走fail
4***@qq.com
请问有人解决了吗?
小白_chen - 前端开发工程师
请问解决了吗?我现在也是遇到这个问题,很棘手。就调试的安卓上没问题,IOS模拟器就一直报这个错误,如果有解决方案希望能贴一下,谢谢。
DCloud_heavensoft
1***@qq.com
有人解决了吗,ios真的不行,直接就走ip定位了