HarmonyOS 调定位各参数含义?

1、调用geoLocationManager.getCurrentLocation(request?: CurrentLocationRequest)获取定位位置。可变参数request可配置priority、scenario、maxAccuracy,timeoutMs。如果不传request,直接调geoLocationManager.getCurrentLocation(),那么定位的那些配置默认分别都是怎么样的?

2、注册位置变化监听的api中参数含义咨询:

let requestInfo:geoLocationManager.LocationRequest = {'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
geoLocationManager.on('locationChange', requestInfo, locationChange);

distanceInterval:这个是指两次位置偏差超过distanceInterval米后会回调吗,还是什么?

maxAccuracy:精度信息,具体表示什么含义意思?

定位回调信息additions中有个provider,看似像是定位来源,该provider共有哪几种值,分别是什么含义?

“additions”:"{“provider”:“network”,“isCache”:true}"

阅读 705
1 个回答

问题1:

priority、scenario、maxAccuracy等可以参考

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-geolocationmanager-0000001815087746-V5\#ZH-CN\_TOPIC\_0000001815087746\_\_locationrequest

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-geolocationmanager-0000001815087746-V5\#ZH-CN\_TOPIC\_0000001815087746\_\_currentlocationrequest

timeoutMs目前默认值为30秒。

如果不传request,直接调geoLocationManager.getCurrentLocation(),那么定位的那些配置都会是默认配置,priority是First\_Fix。

问题2:

distanceInterval:距离间隔,表示监听到两次位置偏差超过distanceInterval米后会回调。

maxAccuracy:精度信息,筛选展示中心点maxAccuracy米内的坐标。

定位回调信息additions中有个provider,目前只提供network这一种类型。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进