DEV Community

HarmonyOS
HarmonyOS

Posted on

It takes a long time for the location service to obtain location information

Read the original article:It takes a long time for the location service to obtain location information

Question

It takes a long time for the location service to obtain location information when using the @ohos.geoLocation Manager interface. How to solve it?

Short Answer

The delay occurs because the precision-first policy waits for both GNSS and network positioning results. In poor GPS environments (such as indoors), GNSS cannot provide results, so only the network result is returned after the timeout period, causing a long wait.

To improve performance:

  • Use the speed-first policy if high precision is not required.
  • If precision is required, keep the precision-first policy but add a loading page to notify users about potential delays.

Applicable Scenarios

  • Indoor or weak GPS environments
  • Apps that do not require high-accuracy location
  • Apps requiring high precision with user feedback/loading UI
  • Situations where user experience must be improved during long location retrieval

Reference Link

https://developer.huawei.com/consumer/en/doc/harmonyos-references-V13/js-apis-geolocationmanager-V13#locatingpriority12

Written by Emine INAN

Top comments (0)