文档开发者中心
我的
|

HarmonyOS 5

Codelabs->HarmonyOS NEXT->计步器应用 调用逆地理编码服务出错

收起
自动换行
深色代码主题
复制
官方例子的代码:
private getGeolocation: (location: geoLocationManager.Location) => void = (location: geoLocationManager.Location) => {
  if (this.latitude === location.latitude && this.longitude === location.longitude) {
    return;
  }
  this.latitude = location.latitude;
  this.longitude = location.longitude;
  let reverseGeocodeRequest: geoLocationManager.ReverseGeoCodeRequest = {
    'locale': this.locale.toString().includes('zh') ? 'zh' : 'en',
    'latitude': this.latitude,
    'longitude': this.longitude,
    'maxItems': 1
  };
  geoLocationManager.getAddressesFromLocation(reverseGeocodeRequest).then(data => {
    if (data[0].placeName) {
      this.currentLocation = data[0].placeName;
    }
  }).catch((err: Error) => {
    Logger.error(TAG, 'GetAddressesFromLocation err ' + JSON.stringify(err));
  });
}

用本地模拟器运行,geoLocationManager.getAddressesFromLocation这个调用总是运行到catch((err: Error) => { Logger.error(TAG, 'GetAddressesFromLocation err ' + JSON.stringify(err)); })这报错,错误代码:3301300 错误信息:BussinessError 3301300: Reverse geocoding query failed.

这个例子本地模拟器不能正确运行吗?

点赞
收藏
1
回复
2
分享
举报
浏览353 发布于2024-07-11 02:31甘肃
全部评论
最多点赞
最新发布
最早发布

刚看了模拟器与真机的差异,X86版本的模拟器确实不支持地理逆编码和地图,不能正确运行上述例子。

1
1楼回复于2024-07-11 02:45 来自甘肃
  • XY道衍
    为啥真机也不行呢?
    2024-07-31 01:26 来自重庆
写回答
新增插入模板功能
一键使用模板,快速填写内容,轻松发帖~
知道了
  • 为了保障您的信息安全,请勿上传您的敏感个人信息(如您的密码等信息)和您的敏感资产信息(如关键源代码、签名私钥、调试安装包、业务日志等信息),且您需自行承担由此产生的信息泄露等安全风险。
  • 如您发布的内容为转载内容,请注明内容来源。

我要提问题

了解社区公约,与您携手共创和谐专业的开发者社区。