The Geolocation Manager module provides location service management functions.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Applying for Permissions
Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user as described below.
The system provides the following location permissions:
- ohos.permission.LOCATION
- ohos.permission.APPROXIMATELY_LOCATION
- ohos.permission.LOCATION_IN_BACKGROUND
If your application needs to access the device location information, it must first apply for required permissions. Specifically speaking:
- API versions earlier than 9: Apply for **ohos.permission.LOCATION**.
- API version 9 and later: Apply for **ohos.permission.APPROXIMATELY\_LOCATION**, or apply for **ohos.permission.APPROXIMATELY\_LOCATION** and **ohos.permission.LOCATION**. Note that **ohos.permission.LOCATION** cannot be applied for separately.
| Earlier than 9 | ohos.permission.LOCATION | Success | Location accurate to meters|
| 9 and later | ohos.permission.LOCATION | Failure | No location obtained |
| 9 and later | ohos.permission.APPROXIMATELY_LOCATION | Success | Location accurate to 5 kilometers |
| 9 and later | ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION| Success | Location accurate to meters|
If your application needs to access the device location information when running in the background, it must be configured to be able to run in the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background.
You can declare the required permission in your application's configuration file. For details, see [Access Control (Permission) Development](../../security/accesstoken-guidelines.md).
| type | string | Yes | Event type. The value **countryCodeChange** indicates to unsubscribe from the country code change event.|
| callback | Callback<[CountryCode](#countrycode)> | No | Callback used for unsubscription. If this parameter is not specified, all callbacks of the specified event type are unsubscribed from.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| type | [LocationPrivacyType](#locationprivacytype) | Yes | Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when the location service is enabled. |
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result, which indicates whether the user agrees with the privacy statement. |
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| type | [LocationPrivacyType](#locationprivacytype) | Yes | Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when the location service is enabled. |
| type | [LocationPrivacyType](#locationprivacytype) | Yes | Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when the location service is enabled. |
| isConfirmed | boolean | Yes | Callback used to return the result, which indicates whether the user agrees with the privacy statement. |
| callback | AsyncCallback<void> | Yes | Callback used to return the error message. |
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| type | [LocationPrivacyType](#locationprivacytype) | Yes | Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when the location service is enabled. |
| isConfirmed | boolean | Yes | Callback used to return the result, which indicates whether the user agrees with the privacy statement. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result indicating whether it is successful to enable the function. If so, **nullptr** is returned. Otherwise, an error message is returned.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| Promise<void> | void | No | Promise used to return the result indicating whether it is successful to enable the function. If so, **nullptr** is returned; an error message otherwise.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| callback | AsyncCallback<void> | Yes | Callback used to return the result indicating whether it is successful to disable the function. If so, **nullptr** is returned; an error message otherwise.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| Promise<void> | void | No | Promise used to return the result indicating whether it is successful to disable the function. If so, **nullptr** is returned; an error message otherwise.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| config | [LocationMockConfig](#locationmockconfig) | Yes | Mock location information, including the interval for reporting the mock locations and the array of the mock locations.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result indicating whether it is successful to set the information. If so, **nullptr** is returned; an error message otherwise.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| config | [LocationMockConfig](#locationmockconfig) | Yes | Mock location information, including the interval for reporting the mock locations and the array of the mock locations.|
| Promise<void> | void | No | Promise used to return the result indicating whether it is successful to set the information. If so, **nullptr** is returned; an error message otherwise.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| callback | AsyncCallback<void> | Yes | Callback used to return the result indicating whether it is successful to enable the function. If so, **nullptr** is returned; an error message otherwise.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| Promise<void> | void | No | Promise used to return the result indicating whether it is successful to enable the function. If so, **nullptr** is returned; an error message otherwise.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| callback | AsyncCallback<void> | Yes | Callback used to return the result indicating whether it is successful to disable the function. If so, **nullptr** is returned; an error message otherwise.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| Promise<void> | void | No | Promise used to return the result indicating whether it is successful to disable the function. If so, **nullptr** is returned; an error message otherwise.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
Sets information of the mock reverse geocoding function, including the mapping between a location and geographical name. If the location is contained in the configurations during reverse geocoding query, the corresponding geographical name will be returned.
| mockInfos | Array<[ReverseGeocodingMockInfo](#reversegeocodingmockinfo)> | Yes | Array of information of the mock reverse geocoding function, including a location and a geographical name.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result indicating whether it is successful to set the information. If so, **nullptr** is returned; an error message otherwise.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
Sets information of the mock reverse geocoding function, including the mapping between a location and geographical name. If the location is contained in the configurations during reverse geocoding query, the corresponding geographical name will be returned.
| mockInfos | Array<[ReverseGeocodingMockInfo](#reversegeocodingmockinfo)> | Yes | Array of information of the mock reverse geocoding function, including a location and a geographical name.|
| Promise<void> | void | No | Promise used to return the result indicating whether it is successful to set the information. If so, **nullptr** is returned; an error message otherwise.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
| DAILY_LIFE_SERVICE | 0x304 | Daily life services. |
| NO_POWER | 0x305 | Power efficiency. Your application does not proactively start the location service. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.|
| locale | string | Yes | Yes | Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| latitude | number | Yes | Yes | Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude. |
| longitude | number | Yes | Yes | Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude . |
| maxItems | number | Yes | Yes | Maximum number of location records to be returned. |
| locale | string | Yes | Yes | Language used for the location description. **zh** indicates Chinese, and **en** indicates English. |
| description | string | Yes | Yes | Location description, for example, **No. xx, xx Road, Pudong New District, Shanghai**. |
| maxItems | number | Yes | Yes | Maximum number of location records to be returned. |
| minLatitude | number | Yes | Yes | Minimum latitude. This parameter is used with **minLongitude**, **maxLatitude**, and **maxLongitude** to specify the latitude and longitude ranges.|
| priority | [LocationRequestPriority](#locationrequestpriority) | Yes | Yes | Priority of the location request. |
| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes | Yes | Scenario of the location request. |
| timeInterval | number | Yes | Yes | Time interval at which location information is reported. |
| distanceInterval | number | Yes | Yes | Distance interval at which location information is reported. |
| maxAccuracy | number | Yes | Yes | Location accuracy. This parameter is valid only when the precise location function is enabled, and is invalid when the approximate location function is enabled.|
| priority | [LocationRequestPriority](#locationrequestpriority) | Yes | Yes | Priority of the location request. |
| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes | Yes | Scenario of the location request. |
| maxAccuracy | number | Yes | Yes | Location accuracy, in meters. This parameter is valid only when the precise location function is enabled, and is invalid when the approximate location function is enabled.|
| timeoutMs | number | Yes | Yes | Timeout duration, in milliseconds. The minimum value is **1000**. |
| reportingPeriodSec | number | Yes | Yes | Interval for reporting the cached GNSS locations, in milliseconds. |
| wakeUpCacheQueueFull | boolean | Yes | Yes | **true**: reports the cached GNSS locations to the application when the cache queue is full.<br/>**false**: discards the cached GNSS locations when the cache queue is full. |
## Geofence
Defines a GNSS geofence. Currently, only circular geofences are supported.
Location services provide basic functions such as GNSS positioning, network positioning, geocoding, reverse geocoding, country code and geofencing.
The Geolocation module provides location services such as GNSS positioning, network positioning, geocoding, reverse geocoding, country code and geofencing.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [geoLocationManager](js-apis-geoLocationManager.md) instead.
## Applying for Permissions
Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user as described below.
The system provides the following location permissions:
- ohos.permission.LOCATION
- ohos.permission.APPROXIMATELY_LOCATION
- ohos.permission.LOCATION_IN_BACKGROUND
If your application needs to access the device location information, it must first apply for required permissions. Specifically speaking:
API versions earlier than 9: Apply for **ohos.permission.LOCATION**.
API version 9 and later: Apply for **ohos.permission.APPROXIMATELY\_LOCATION**, or apply for **ohos.permission.APPROXIMATELY\_LOCATION** and **ohos.permission.LOCATION**. Note that **ohos.permission.LOCATION** cannot be applied for separately.
| API Version| Location Permission| Permission Application Result| Location Accuracy|
| -------- | -------- | -------- | -------- |
| Earlier than 9| ohos.permission.LOCATION | Success| Location accurate to meters|
| 9 and later| ohos.permission.LOCATION | Failure| No location obtained|
| 9 and later| ohos.permission.APPROXIMATELY_LOCATION | Success| Location accurate to 5 kilometers|
| 9 and later| ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION| Success| Location accurate to meters|
If your application needs to access the device location information when running in the background, it must be configured to be able to run in the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background.
You can declare the required permission in your application's configuration file. For details, see [Access Control (Permission) Development](../../security/accesstoken-guidelines.md).
Registers a listener for location changes with a location request initiated.
Registers a listener for location changes with a location request initiated. The location result is reported through [LocationRequest](#locationrequest).
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationchange).
Unregisters the listener for location changes with the corresponding location request deleted.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationchange).
@@ -58,12 +94,12 @@ Unregisters the listener for location changes with the corresponding location re
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **locationChange** indicates a location change event.|
| callback | Callback<[Location](#location)> | No| Callback used to return the location change event.|
| callback | Callback<[Location](#location)> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
Registers a listener for location service status change events.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationEnabledChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationenabledchange).
Unregisters the listener for location service status change events.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationEnabledChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationenabledchange).
@@ -118,12 +160,12 @@ Unregisters the listener for location service status change events.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **locationServiceState** indicates a location service status change event.|
| callback | Callback<boolean> | No| Callback used to return the location service status change event.|
| callback | Callback<boolean> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
Registers a listener for cached GNSS location reports.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('cachedGnssLocationsChange')](js-apis-geoLocationManager.md#geolocationmanageroncachedgnsslocationschange).
Unregisters the listener for cached GNSS location reports.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('cachedGnssLocationsChange')](js-apis-geoLocationManager.md#geolocationmanageroffcachedgnsslocationschange).
@@ -179,12 +229,12 @@ Unregisters the listener for cached GNSS location reports.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **cachedGnssLocationsReporting** indicates reporting of cached GNSS locations.|
| callback | Callback<boolean> | No| Callback used to return cached GNSS locations.|
| callback | Callback<Array<[Location](#location)>> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
Registers a listener for GNSS satellite status change events.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('satelliteStatusChange')](js-apis-geoLocationManager.md#geolocationmanageronsatellitestatuschange).
Unregisters the listener for GNSS satellite status change events.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('satelliteStatusChange')](js-apis-geoLocationManager.md#geolocationmanageroffsatellitestatuschange).
@@ -239,11 +297,11 @@ Unregisters the listener for GNSS satellite status change events.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **gnssStatusChange** indicates a GNSS satellite status change.|
| callback | Callback<SatelliteStatusInfo> | No| Callback used to return GNSS satellite status changes.|
| callback | Callback<[SatelliteStatusInfo](#satellitestatusinfo)> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
Registers a listener for GNSS NMEA message change events.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('nmeaMessage')](js-apis-geoLocationManager.md#geolocationmanageronnmeamessage).
Unregisters the listener for GNSS NMEA message change events.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('nmeaMessage')](js-apis-geoLocationManager.md#geolocationmanageroffnmeamessage).
@@ -297,12 +363,12 @@ Unregisters the listener for GNSS NMEA message change events.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **nmeaMessageChange** indicates a GNSS NMEA message change.|
| callback | Callback<string> | No| Callback used to return GNSS NMEA message changes.|
| callback | Callback<string> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
Registers a listener for status change events of the specified geofence.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('gnssFenceStatusChange')](js-apis-geoLocationManager.md#geolocationmanagerongnssfencestatuschange).
Unregisters the listener for status change events of the specified geofence.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('gnssFenceStatusChange')](js-apis-geoLocationManager.md#geolocationmanageroffgnssfencestatuschange).
Obtains the current location. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation).
Obtains the current location. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation).
Obtains the current location. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation-2).
Obtains the previous location. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getLastLocation](js-apis-geoLocationManager.md#geolocationmanagergetlastlocation).
Obtains the previous location. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getLastLocation](js-apis-geoLocationManager.md#geolocationmanagergetlastlocation).
Checks whether the location service is enabled. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isLocationEnabled](js-apis-geoLocationManager.md#geolocationmanagerislocationenabled).
Checks whether the location service is enabled. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isLocationEnabled](js-apis-geoLocationManager.md#geolocationmanagerislocationenabled).
Requests to enable the location service. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.requestEnableLocation](js-apis-geoLocationManager.md#geolocationmanagerrequestenablelocation).
Requests to enable the location service. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.requestEnableLocation](js-apis-geoLocationManager.md#geolocationmanagerrequestenablelocation-1).
Checks whether the (reverse) geocoding service is available. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isGeocoderAvailable](js-apis-geoLocationManager.md#geolocationmanagerisgeocoderavailable).
Checks whether the (reverse) geocoding service is available. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isGeocoderAvailable](js-apis-geoLocationManager.md#geolocationmanagerisgeocoderavailable).
Converts coordinates into geographic description through reverse geocoding. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocation](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocation).
Converts coordinates into geographic description through reverse geocoding. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocation](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocation-1).
@@ -876,13 +897,13 @@ Converts coordinates into geographic description through reverse geocoding. This
**Return value**
| Name| Description|
| -------- | -------- |
| Promise<Array<[GeoAddress](#geoaddress)>> | Promise used to return the reverse geocoding result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| Promise<Array<[GeoAddress](#geoaddress)>> | Array<[GeoAddress](#geoaddress)>|NA|Promise used to return the reverse geocoding result.|
Converts geographic description into coordinates through geocoding. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocationName](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocationname).
Converts geographic description into coordinates through geocoding. This API uses a promise to return the result.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocationName](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocationname-1).
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCachedGnssLocationsSize](js-apis-geoLocationManager.md#geolocationmanagergetcachedgnsslocationssize).
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCachedGnssLocationsSize](js-apis-geoLocationManager.md#geolocationmanagergetcachedgnsslocationssize-1).
Obtains all cached GNSS locations and clears the GNSS cache queue.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.flushCachedGnssLocations](js-apis-geoLocationManager.md#geolocationmanagerflushcachedgnsslocations).
Obtains all cached GNSS locations and clears the GNSS cache queue.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.flushCachedGnssLocations](js-apis-geoLocationManager.md#geolocationmanagerflushcachedgnsslocations-1).
Sends an extended command to the location subsystem. This API can only be called by system applications.
Sends an extended command to the location subsystem.
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.sendCommand](js-apis-geoLocationManager.md#geolocationmanagersendcommand).
Sends an extended command to the location subsystem. This API can only be called by system applications.
Sends an extended command to the location subsystem.
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.sendCommand](js-apis-geoLocationManager.md#geolocationmanagersendcommand).
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationRequestPriority](js-apis-geoLocationManager.md#locationrequestpriority).
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationRequestScenario](js-apis-geoLocationManager.md#locationrequestscenario).
@@ -1171,15 +1228,18 @@ Sets the priority of the location request.
| NO_POWER | 0x305 | Power efficiency. Your application does not proactively start the location service. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.|
| REVERSE_GEOCODE_ERROR<sup>7+</sup> | 102 | Failed to call the reverse geocoding API.|
...
...
@@ -1190,213 +1250,255 @@ Enumerates error codes of the location service.
| LOCATION_REQUEST_TIMEOUT_ERROR<sup>7+</sup> | 107 | Failed to obtain the location within the specified time.|
## ReverseGeoCodeRequest
## ReverseGeoCodeRequest<sup>(deprecated) </sup>
Defines a reverse geocoding request.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.ReverseGeoCodeRequest](js-apis-geoLocationManager.md#reversegeocoderequest).
| locale | string | Yes| Yes| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| latitude | number | Yes| Yes| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.|
| longitude | number | Yes| Yes| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .|
| maxItems | number | Yes| Yes| Maximum number of location records to be returned.|
## GeoCodeRequest
## GeoCodeRequest<sup>(deprecated) </sup>
Defines a geocoding request.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.GeoCodeRequest](js-apis-geoLocationManager.md#geocoderequest).
| locale | string | No| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| description | number | Yes| Location description, for example, No. xx, xx Road, Pudong New District, Shanghai.|
| maxItems | number | No| Maximum number of location records to be returned.|
| minLatitude | number | No| Minimum latitude. This parameter is used with minLongitude, maxLatitude, and maxLongitude to specify the latitude and longitude ranges.|
| locale | string | Yes| Yes| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| description | string | Yes| Yes| Location description, for example, **No. xx, xx Road, Pudong New District, Shanghai**.|
| maxItems | number | Yes| Yes| Maximum number of location records to be returned.|
| minLatitude | number | Yes| Yes| Minimum latitude. This parameter is used with **minLongitude**, **maxLatitude**, and **maxLongitude** to specify the latitude and longitude ranges.|
| minLongitude | number | Yes| Yes| Minimum longitude.|
| maxLatitude | number | Yes| Yes| Maximum latitude.|
| maxLongitude | number | Yes| Yes| Maximum longitude.|
## GeoAddress
## GeoAddress<sup>(deprecated) </sup>
Defines a geographic location.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.GeoAddress](js-apis-geoLocationManager.md#geoaddress).
| latitude<sup>7+</sup> | number | No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.|
| longitude<sup>7+</sup> | number | No| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .|
| locale<sup>7+</sup> | string | No| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| placeName<sup>7+</sup> | string | No| Landmark of the location.|
| countryCode<sup>7+</sup> | string | No| Country code.|
| countryName<sup>7+</sup> | string | No| Country name.|
| administrativeArea<sup>7+</sup> | string | No| Administrative region name.|
| subAdministrativeArea<sup>7+</sup> | string | No| Sub-administrative region name.|
| latitude<sup>7+</sup> | number | Yes| No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.|
| longitude<sup>7+</sup> | number | Yes| No| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .|
| locale<sup>7+</sup> | string | Yes| No| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| placeName<sup>7+</sup> | string | Yes| No| Landmark of the location.|
| countryCode<sup>7+</sup> | string | Yes| No| Country code.|
| countryName<sup>7+</sup> | string | Yes| No| Country name.|
| administrativeArea<sup>7+</sup> | string | Yes| No| Administrative region name.|
| subAdministrativeArea<sup>7+</sup> | string | Yes| No| Sub-administrative region name.|
| descriptionsSize<sup>7+</sup> | number | Yes| No| Total number of additional descriptions.|
## LocationRequest<sup>(deprecated) </sup>
Defines a location request.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationRequest](js-apis-geoLocationManager.md#locationrequest).
| priority | [LocationRequestPriority](#locationrequestpriority) | Yes| Yes| Priority of the location request.|
| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes| Yes| Scenario of the location request.|
| timeInterval | number | Yes| Yes| Time interval at which location information is reported.|
| distanceInterval | number | Yes| Yes| Distance interval at which location information is reported.|
| maxAccuracy | number | Yes| Yes| Location accuracy. This parameter is valid only when the precise location function is enabled, and is invalid when the approximate location function is enabled.|
## CurrentLocationRequest
## CurrentLocationRequest<sup>(deprecated) </sup>
Defines the current location request.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CurrentLocationRequest](js-apis-geoLocationManager.md#currentlocationrequest).
| priority | [LocationRequestPriority](#locationrequestpriority) | Yes| Yes| Priority of the location request.|
| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes| Yes| Scenario of the location request.|
| maxAccuracy | number | Yes| Yes| Location accuracy, in meters. This parameter is valid only when the precise location function is enabled, and is invalid when the approximate location function is enabled.|
| timeoutMs | number | Yes| Yes| Timeout duration, in milliseconds. The minimum value is **1000**.|
## SatelliteStatusInfo<sup>8+</sup>
## SatelliteStatusInfo<sup>(deprecated) </sup>
Defines the satellite status information.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.SatelliteStatusInfo](js-apis-geoLocationManager.md#satellitestatusinfo).
Represents a request for reporting cached GNSS locations.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CachedGnssLocationsRequest](js-apis-geoLocationManager.md#cachedgnsslocationsrequest).
| reportingPeriodSec | number | Yes| Interval for reporting the cached GNSS locations, in milliseconds.|
| wakeUpCacheQueueFull | boolean | Yes| **true**: reports the cached GNSS locations to the application when the cache queue is full.<br>**false**: discards the cached GNSS locations when the cache queue is full.|
| reportingPeriodSec | number | Yes| Yes| Interval for reporting the cached GNSS locations, in milliseconds.|
| wakeUpCacheQueueFull | boolean | Yes| Yes | **true**: reports the cached GNSS locations to the application when the cache queue is full.<br>**false**: discards the cached GNSS locations when the cache queue is full.|
## Geofence<sup>8+</sup>
## Geofence<sup>(deprecated) </sup>
Defines a GNSS geofence. Currently, only circular geofences are supported.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.Geofence](js-apis-geoLocationManager.md#geofence).
| latitude | number | Yes| Yes | Latitude information.|
| longitude | number | Yes| Yes | Longitude information.|
| radius | number | Yes| Yes | Radius of a circular geofence.|
| expiration | number | Yes| Yes | Expiration period of a geofence, in milliseconds.|
## GeofenceRequest<sup>8+</sup>
## GeofenceRequest<sup>(deprecated) </sup>
Represents a GNSS geofencing request.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.GeofenceRequest](js-apis-geoLocationManager.md#geofencerequest).
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationPrivacyType](js-apis-geoLocationManager.md#locationprivacytype).
| STARTUP | 1 | Privacy statement displayed in the startup wizard.|
| CORE_LOCATION | 2 | Privacy statement displayed when enabling the location service.|
## LocationCommand<sup>8+</sup>
## LocationCommand<sup>(deprecated) </sup>
Defines an extended command.
**Permission required**: ohos.permission.LOCATION
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationCommand](js-apis-geoLocationManager.md#locationcommand).
| latitude<sup>7+</sup> | number | Yes| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.|
| longitude<sup>7+</sup> | number | Yes| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .|
| altitude<sup>7+</sup> | number | Yes| Location altitude, in meters.|
| accuracy<sup>7+</sup> | number | Yes| Location accuracy, in meters.|
| speed<sup>7+</sup> | number | Yes| Speed, in m/s.|
| timeStamp<sup>7+</sup> | number | Yes| Location timestamp in the UTC format.|
| direction<sup>7+</sup> | number | Yes| Direction information.|
| timeSinceBoot<sup>7+</sup> | number | Yes| Location timestamp since boot.|
| latitude<sup>7+</sup> | number | Yes| No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.|
| longitude<sup>7+</sup> | number | Yes| No| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .|
| altitude<sup>7+</sup> | number | Yes| No| Location altitude, in meters.|
| accuracy<sup>7+</sup> | number | Yes| No| Location accuracy, in meters.|
| speed<sup>7+</sup> | number | Yes| No| Speed, in m/s.|
| timeStamp<sup>7+</sup> | number | Yes| No| Location timestamp in the UTC format.|
| direction<sup>7+</sup> | number | Yes| No| Direction information.|
| timeSinceBoot<sup>7+</sup> | number | Yes| No| Location timestamp since boot.|
This error code is reported when the location service is unavailable and relevant APIs cannot be called.
**Possible Causes**
1. The location service fails to be started. As a result, the communication between the application and the location service fails, and the location service is unavailable.
2. The GNSS chip fails to be initialized, and thus the GNSS positioning function becomes invalid.
3. The network positioning service is abnormal, and thus the network positioning function becomes invalid.
**Solution**
Stop calling the API.
## 3301100 Location Service Unavailable Because of Switch Toggled Off
**Error Message**
The location switch is off.
**Description**
This error code is reported when the location service is unavailable because the service switch is toggled off.
**Possible Causes**
The location service switch is toggled off, which makes basic functions such as continuous positioning and immediate positioning unavailable.
**Solution**
Display a prompt asking for enabling the location service.
## 3301200 Failure to Obtain the Positioning Result
**Error Message**
Failed to obtain the geographical location.
**Description**
This error code is reported when the location service fails, and no positioning result is obtained.
**Possible Causes**
1. Positioning timed out because of weak GNSS signals.
2. Positioning timed out because the network positioning service is abnormal.
**Solution**
Initiate a positioning request again.
## 3301300 Reverse Geocoding Query Failure
**Error Message**
Reverse geocoding query failed.
**Description**
This error code is reported for a reverse geocoding query failure.
**Possible Causes**
Network connection is poor, which makes the request fail to be sent from the device or the result fail to be returned from the cloud to the device.
**Solution**
Try the reverse geocoding query again.
## 3301400 Geocoding Query Failure
**Error Message**
Geocoding query failed.
**Description**
This error code is reported for a geocoding query failure.
**Possible Causes**
Network connection is poor, which makes the request fail to be sent from the device or the result fail to be returned from the cloud to the device.
**Solution**
Try the geocoding query again.
## 3301500 Area Information Query Failure
**Error Message**
Failed to query the area information.
**Description**
This error code is reported for the failure to query the area information (including the country code).
**Possible Causes**
The correct area information is not found.
**Solution**
Stop calling the API for querying the country code.
## 3301600 Geofence Operation Failure
**Error Message**
Failed to operate the geofence.
**Description**
This error code is reported when an operation (like adding, deleting, pausing, and resuming) fails to be performed on the geofence.
**Possible Causes**
1. The GNSS chip does not support the geofence function.
2. The bottom-layer service logic is abnormal.
**Solution**
Stop calling the geofence operation API.
## 3301700 No Response to the Request
**Error Message**
No response to the request.
**Description**
This error code is reported when no response is received for an asynchronous request that requires a user to click a button for confirmation or requires a response from the GNSS chip or network server.
**Possible Causes**
1. The user does not click a button as required for confirmation.