9***@qq.com
9***@qq.com
  • 发布:2025-05-28 11:38
  • 更新:2025-05-30 16:05
  • 阅读:126

【报Bug】getCenterLocation 方法在app端返回空{},无法获取到经纬度

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 11

HBuilderX类型: 正式

HBuilderX版本号: 4.66

手机系统: Android

手机系统版本号: Android 16

手机厂商: 小米

手机机型: 小米

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

this.mapContext.getCenterLocation({
// type: 'gcj02',
// geocode: true,
// isHighAccuracy: true,
// altitude: true,
success: (res) => {
console.log(res)
this.location.longitude = res.longitude
this.location.latitude = res.latitude
if (this.enableLocationScope) {
const discount = this.jnpf.getDistance(this.currentLocation.latitude, this
.currentLocation.longitude, this.location.latitude, this.location.longitude
) || 0;
if (discount > (this.adjustmentScope || 500)) return this.$refs.uTips.show({
title: '超出微调范围',
type: 'warning',
});
}
this.getList()
}
})

操作步骤:

预期结果:

获取到中心点坐标

实际结果:

返回{},获取不到中心点坐标

bug描述:

在app真机上调用地图的getCenterLocation方法,获取不到中心店坐标,res返回是{}

2025-05-28 11:38 负责人:无 分享
已邀请:
DCloud_UNI_yuhe

DCloud_UNI_yuhe

你加个fail逻辑,看下有报错吗?

  • 9***@qq.com (作者)

    测试了,没有进入fail,截图在下面

    2025-05-28 13:56

  • DCloud_UNI_yuhe

    回复 9***@qq.com: 也可能是hbuilderx的问题,是控制台不显示了,但是实际上是有值的,你直接打印res中的数值试一下,如果它没.latitude之类的,那么应该直接报错

    2025-05-28 14:33

  • 9***@qq.com (作者)

    回复 DCloud_UNI_yuhe测了一下,直接打印是undefined

    2025-05-28 14:44

  • DCloud_UNI_yuhe

    回复 9***@qq.com: 你之前是好的吗?是升级产生的吗?使用的自定义基座吗?

    2025-05-28 14:47

  • 9***@qq.com (作者)

    回复 DCloud_UNI_yuhe:之前是可以的,是直接运行到安卓app基座

    2025-05-28 14:51

9***@qq.com

9***@qq.com (作者)

测试了,没有进入fail

9***@qq.com

9***@qq.com (作者)

搞不懂什么问题

9***@qq.com

9***@qq.com (作者)

有结果吗

1***@qq.com

1***@qq.com

你好,遇见同样的问题,升级之后,ios手机上通过getCenterLocation获取中心点位置,返回{}, 没有返回经纬度,请问解决了吗?麻烦看到回复一下

要回复问题请先登录注册