@@ -23,12 +23,12 @@ If your application needs to access the device location information, it must fir
- 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|
| 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.
...
...
@@ -42,823 +42,1675 @@ import geoLocationManager from '@ohos.geoLocationManager';
Registers a listener for location changes with a location request initiated. The location result is reported through [LocationRequest](#locationrequest).
| 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **locationChange** indicates a 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.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md).
| Promise<void> | void | No | Promise used to return the error message.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **locationEnabledChange** indicates a 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.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md).
| Promise<void> | void | No | Promise used to return the error code.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **cachedGnssLocationsChange** indicates reporting of cached GNSS locations.|
| callback | Callback<boolean> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **satelliteStatusChange** indicates a GNSS satellite status change event.|
| callback | Callback<[SatelliteStatusInfo](#satellitestatusinfo)> | Yes| Callback used to return GNSS satellite status changes.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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. |
| Promise<boolean> | boolean | No | Callback used to return the result, which indicates whether the user agrees with the privacy statement.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **satelliteStatusChange** indicates a GNSS satellite status change event.|
| callback | Callback<[SatelliteStatusInfo](#satellitestatusinfo)> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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 error message. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **nmeaMessage** indicates a GNSS NMEA message change event.|
| callback | Callback<string> | Yes| Callback used to return GNSS NMEA message changes.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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. |
| Promise<void> | void | No | Promise used to return the error code.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **nmeaMessage** indicates a GNSS NMEA message change event.|
| callback | Callback<string> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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. Otherwise, an error message is returned.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **countryCodeChange** indicates a country code change event.|
| callback | Callback<[CountryCode](#countrycode)> | Yes| Callback used to return the country code change event.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value **countryCodeChange** indicates a country code change event.|
| callback | Callback<[CountryCode](#countrycode)> | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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.|
| 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[Location](#location)> | Yes| Callback used to return the current location.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. The value **true** indicates that the user agrees to enable the location service, and the value **false** indicates the opposite.|
**Error codes**
For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md).
| Promise<boolean> | boolean | NA | Promise used to return the result. The value **true** indicates that the user agrees to enable the location service, and the value **false** indicates the opposite.|
**Error codes**
For details about the following error codes, see [Location Error Codes](../errorcodes/errorcode-geoLocationManager.md).
| Promise<Array<[GeoAddress](#geoaddress)>> | Array<[GeoAddress](#geoaddress)> | NA | Promise used to return the reverse geocoding result.|
**Error codes**
For details about the following error codes, see [Location Error Codes](../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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| command | [LocationCommand](#locationcommand) | Yes| Extended command (string) to be sent.|
| 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| Promise<void> | void | NA | Promise used to return the error code.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[CountryCode](#countrycode)> | Yes| Callback used to return the country code.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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.|
| 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [LocationMockConfig](#locationmockconfig) | Yes| Mock location information, including the interval for reporting the mock locations and the array of the mock locations.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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.|
**System API**: This is a system API and cannot be called by third-party applications.
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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.
...
...
@@ -942,21 +1823,20 @@ Sets information of the mock reverse geocoding function, including the mapping b
| 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| mockInfos | Array<[ReverseGeocodingMockInfo](#reversegeocodingmockinfo)> | Yes| Array of information of the mock reverse geocoding function, including a location and a geographical name.|
**Error codes**
For details about the following error codes, see [error codes of the location service](../errorcodes/errorcode-geoLocationManager.md).
For details about the following error codes, see [Location Error Codes](../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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| boolean | boolean | NA | 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).
For details about the following error codes, see [Location Error Codes](../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.|
**Error codes**
For details about the following error codes, see [Location Error Codes](../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.|
| 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.|
## ReverseGeoCodeRequest
...
...
@@ -1063,12 +1971,12 @@ Defines a reverse geocoding request.
| 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.|
| 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
...
...
@@ -1094,27 +2002,27 @@ Defines a geographic location.
| 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.|
| 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
...
...
@@ -1138,12 +2046,12 @@ Defines the current location request.
| 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**. |
| 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
...
...
@@ -1152,14 +2060,14 @@ Defines the satellite status information.
| 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. |
| 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
...
...
@@ -1180,12 +2088,12 @@ Defines a GNSS geofence. Currently, only circular geofences are supported.