uni.getLocation({
//type: 'gcj02',
//isHighAccuracy:true,
success: function (res) {
console.log('获取定位:' + res);
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
},
fail: (err) => {
console.error('定位失败', err);

- 发布:2025-09-15 10:09
- 更新:2025-09-15 12:14
- 阅读:16
【报Bug】运行到鸿蒙,模拟器返回 getLocation:fail maybe not turn on the system location permission无法获取经纬度
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 22H2
HBuilderX类型: 正式
HBuilderX版本号: 4.76
手机系统: HarmonyOS NEXT
手机系统版本号: HarmonyOS 5.0.5
手机厂商: 模拟器
手机机型: DevEco Studio 5.1.1 Release
页面类型: vue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
App下载地址或H5⽹址: 当前的鸿蒙项目没有打包在开发阶段
示例代码:
操作步骤:
uni.getLocation({
//type: 'gcj02',
//isHighAccuracy:true,
success: function (res) {
console.log('获取定位:' + res);
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
},
fail: (err) => {
console.error('定位失败', err);
uni.getLocation({
//type: 'gcj02',
//isHighAccuracy:true,
success: function (res) {
console.log('获取定位:' + res);
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
},
fail: (err) => {
console.error('定位失败', err);
预期结果:
返回经度纬度
返回经度纬度
实际结果:
返回提示errMsg: "getLocation:fail maybe not turn on the system location permission."
返回提示errMsg: "getLocation:fail maybe not turn on the system location permission."
bug描述:
调用 uni.getLocation返回问题,
已经按要求在项目 中的harmony-configs 中设置 module.json5与string.json,采用腾讯地图配置了 key(截图5),当运行调用uni.getLocation弹窗出位置权限申请,如附件1权限申请截图,如点击【不允许】返回:定位失败 {errMsg: "getLocation:fail maybe not obtain GPS Permission.",如点击【本次允许、使用期间允许】返回定位失败 {errMsg: "getLocation:fail maybe not turn on the system location permission."
getLocation:fail maybe not turn on the system location permission,在鸿蒙模拟器中(HarmonyOs 5.1.1(19))中无定位服务,模拟器中的 gps模拟已经手动设置纬度与经度(见截图2gps),模拟器中应用设置了是允许(截图3设置)
网络上查询不到errMsg: "getLocation:fail maybe not turn on the system location permission 的相关文章,现无法获取经纬度,敬请管理员给个相关建议



