#鸿蒙通关秘籍#不用高德或者百度这些sdk的话,用原生能力如拿到自己当前的准确位置?

HarmonyOS
2024-12-06 15:19:54
4904浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
SKU流星赶月
import { geoLocationManager } from '@kit.LocationKit';
import { BusinessError } from '@kit.BasicServicesKit'

let requestInfo: geoLocationManager.CurrentLocationRequest = {
  'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX,
  'scenario': geoLocationManager.LocationRequestScenario.UNSET,
  'maxAccuracy': 0
};

try {
  geoLocationManager.getCurrentLocation(requestInfo).then((result) => {
    console.log('current location: ' + JSON.stringify(result));
  })
  .catch((error: BusinessError) => {
    console.error('promise, getCurrentLocation: error=' + JSON.stringify(error));
  });
} catch (err) {
  console.error("errCode:" + JSON.stringify(err));
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
分享
微博
QQ
微信
回复
2024-12-06 17:02:17
相关问题
百度地图坐标系影响距离计算吗?
4008浏览 • 1回复 待解决
harmonyOS SDK 原生广告问题
1143浏览 • 0回复 待解决
HarmonyOS 无法显示自己位置图标
680浏览 • 1回复 待解决
HarmonyOS 获取当前定位不准确
1831浏览 • 1回复 待解决
基于原生能力组件封装
1383浏览 • 1回复 待解决
基于原生水印添加能力
1750浏览 • 1回复 待解决
基于原生能力跨应用跳转
1729浏览 • 1回复 待解决
HarmonyOS原生分享能力使用
1743浏览 • 1回复 待解决