1e41f4b71Sopenharmony_ci# @ohos.geolocation (Geolocation) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **geolocation** module provides a wide array of location services, including GNSS positioning, network positioning, geocoding, reverse geocoding, and geofencing. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 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. 7e41f4b71Sopenharmony_ci> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [geoLocationManager](js-apis-geoLocationManager.md). 8e41f4b71Sopenharmony_ci> This module supports only the WGS-84 coordinate system. 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## Applying for Permissions 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ciBefore 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. 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ciThe system provides the following location permissions: 15e41f4b71Sopenharmony_ci- ohos.permission.LOCATION 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci- ohos.permission.APPROXIMATELY_LOCATION 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci- ohos.permission.LOCATION_IN_BACKGROUND 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciIf your application needs to access the device location information, it must first apply for required permissions. Specifically speaking: 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciAPI versions earlier than 9: Apply for **ohos.permission.LOCATION**. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ciAPI 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. 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci| API Version| Location Permission| Permission Application Result| Location Accuracy| 28e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 29e41f4b71Sopenharmony_ci| Earlier than 9| ohos.permission.LOCATION | Successful| Location accurate to meters.| 30e41f4b71Sopenharmony_ci| 9 and later| ohos.permission.LOCATION | Failed| No location obtained.| 31e41f4b71Sopenharmony_ci| 9 and later| ohos.permission.APPROXIMATELY_LOCATION | Successful| Location accurate to 5 kilometers.| 32e41f4b71Sopenharmony_ci| 9 and later| ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION| Successful| Location accurate to meters.| 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ciTo access the device location information when running in the background, an application needs to request for the **ohos.permission.LOCATION_IN_BACKGROUND** permission or a continuous task of the background mode. In this way, the system continues to report device location information after your application moves to the background. 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ciA user can grant the **ohos.permission.LOCATION_IN_BACKGROUND** permission for an application on the setting page. For details, see [ohos.permission.LOCATION_IN_BACKGROUND](../../security/AccessToken/permissions-for-all.md#ohospermissionlocation_in_background). 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ciFor details about how to request for a continuous task, see [Continuous Task](../../task-management/continuous-task.md). 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ciYou can declare the required permission in your application's configuration file. For details, see [Requesting User Authorization](../../security/AccessToken/request-user-authorization.md). 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci## Modules to Import 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci```ts 46e41f4b71Sopenharmony_ciimport geolocation from '@ohos.geolocation'; 47e41f4b71Sopenharmony_ci``` 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci## geolocation.on('locationChange')<sup>(deprecated)</sup> 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_cion(type: 'locationChange', request: LocationRequest, callback: Callback<Location>): void 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ciRegisters a listener for location changes with a location request initiated. This API uses an asynchronous callback to return the result. 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci> **NOTE**<br> 56e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationchange). 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci**Parameters** 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 65e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 66e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **locationChange** indicates a location change event.| 67e41f4b71Sopenharmony_ci | request | [LocationRequest](#locationrequestdeprecated) | Yes| Location request.| 68e41f4b71Sopenharmony_ci | callback | Callback<[Location](#locationdeprecated)> | Yes| Callback used to return the result.| 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci**Example** 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci ```ts 75e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 76e41f4b71Sopenharmony_ci let requestInfo:geolocation.LocationRequest = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; 77e41f4b71Sopenharmony_ci let locationChange = (location:geolocation.Location):void => { 78e41f4b71Sopenharmony_ci console.log('locationChanger: data: ' + JSON.stringify(location)); 79e41f4b71Sopenharmony_ci }; 80e41f4b71Sopenharmony_ci geolocation.on('locationChange', requestInfo, locationChange); 81e41f4b71Sopenharmony_ci ``` 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci## geolocation.off('locationChange')<sup>(deprecated)</sup> 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_cioff(type: 'locationChange', callback?: Callback<Location>): void 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ciUnregisters the listener for location changes with the corresponding location request deleted. 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci> **NOTE**<br> 91e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationchange). 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci**Parameters** 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 100e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 101e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **locationChange** indicates a location change event.| 102e41f4b71Sopenharmony_ci | callback | Callback<[Location](#locationdeprecated)> | No| Callback to unregister. The callback must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks of the specified event type are unregistered.| 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ci**Example** 106e41f4b71Sopenharmony_ci 107e41f4b71Sopenharmony_ci ```ts 108e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 109e41f4b71Sopenharmony_ci let requestInfo:geolocation.LocationRequest = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; 110e41f4b71Sopenharmony_ci let locationChange = (location:geolocation.Location):void => { 111e41f4b71Sopenharmony_ci console.log('locationChanger: data: ' + JSON.stringify(location)); 112e41f4b71Sopenharmony_ci }; 113e41f4b71Sopenharmony_ci geolocation.on('locationChange', requestInfo, locationChange); 114e41f4b71Sopenharmony_ci geolocation.off('locationChange', locationChange); 115e41f4b71Sopenharmony_ci ``` 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci## geolocation.on('locationServiceState')<sup>(deprecated)</sup> 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_cion(type: 'locationServiceState', callback: Callback<boolean>): void 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ciRegisters a listener for location service status change events. This API uses an asynchronous callback to return the result. 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci> **NOTE**<br> 125e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationEnabledChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationenabledchange). 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci**Parameters** 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 134e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 135e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **locationServiceState** indicates a location service status change event.| 136e41f4b71Sopenharmony_ci | callback | Callback<boolean> | Yes| Callback used to return the result. The value **true** indicates that the location service is enabled, and the value **false** indicates the opposite.| 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ci**Example** 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci ```ts 142e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 143e41f4b71Sopenharmony_ci let locationServiceState = (state:boolean):void => { 144e41f4b71Sopenharmony_ci console.log('locationServiceState: ' + JSON.stringify(state)); 145e41f4b71Sopenharmony_ci } 146e41f4b71Sopenharmony_ci geolocation.on('locationServiceState', locationServiceState); 147e41f4b71Sopenharmony_ci ``` 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci## geolocation.off('locationServiceState')<sup>(deprecated)</sup> 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_cioff(type: 'locationServiceState', callback?: Callback<boolean>): void; 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ciUnregisters the listener for location service status change events. 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci> **NOTE**<br> 157e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationEnabledChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationenabledchange). 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 162e41f4b71Sopenharmony_ci 163e41f4b71Sopenharmony_ci**Parameters** 164e41f4b71Sopenharmony_ci 165e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 166e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 167e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **locationServiceState** indicates a location service status change event.| 168e41f4b71Sopenharmony_ci | callback | Callback<boolean> | No| Callback to unregister. The callback must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks of the specified event type are unregistered.| 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ci 171e41f4b71Sopenharmony_ci**Example** 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ci ```ts 174e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 175e41f4b71Sopenharmony_ci let locationServiceState = (state:boolean):void => { 176e41f4b71Sopenharmony_ci console.log('locationServiceState: state: ' + JSON.stringify(state)); 177e41f4b71Sopenharmony_ci } 178e41f4b71Sopenharmony_ci geolocation.on('locationServiceState', locationServiceState); 179e41f4b71Sopenharmony_ci geolocation.off('locationServiceState', locationServiceState); 180e41f4b71Sopenharmony_ci ``` 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci 183e41f4b71Sopenharmony_ci## geolocation.on('cachedGnssLocationsReporting')<sup>(deprecated)</sup> 184e41f4b71Sopenharmony_ci 185e41f4b71Sopenharmony_cion(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback<Array<Location>>): void; 186e41f4b71Sopenharmony_ci 187e41f4b71Sopenharmony_ciRegisters a listener for cached GNSS location reports. This API uses an asynchronous callback to return the result. 188e41f4b71Sopenharmony_ci 189e41f4b71Sopenharmony_ci> **NOTE**<br> 190e41f4b71Sopenharmony_ci> This API is supported since API version 8. 191e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('cachedGnssLocationsChange')](js-apis-geoLocationManager.md#geolocationmanageroncachedgnsslocationschange). 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 196e41f4b71Sopenharmony_ci 197e41f4b71Sopenharmony_ci**Parameters** 198e41f4b71Sopenharmony_ci 199e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 200e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 201e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **cachedGnssLocationsReporting** indicates reporting of cached GNSS locations.| 202e41f4b71Sopenharmony_ci | request | [CachedGnssLocationsRequest](#cachedgnsslocationsrequestdeprecated) | Yes| Request for reporting cached GNSS location.| 203e41f4b71Sopenharmony_ci | callback | Callback<Array<[Location](#locationdeprecated)>> | Yes| Callback used to return the result.| 204e41f4b71Sopenharmony_ci 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci**Example** 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci ```ts 209e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 210e41f4b71Sopenharmony_ci let cachedLocationsCb = (locations:Array<geolocation.Location>):void => { 211e41f4b71Sopenharmony_ci console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); 212e41f4b71Sopenharmony_ci } 213e41f4b71Sopenharmony_ci let requestInfo:geolocation.CachedGnssLocationsRequest = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true}; 214e41f4b71Sopenharmony_ci geolocation.on('cachedGnssLocationsReporting', requestInfo, cachedLocationsCb); 215e41f4b71Sopenharmony_ci ``` 216e41f4b71Sopenharmony_ci 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ci## geolocation.off('cachedGnssLocationsReporting')<sup>(deprecated)</sup> 219e41f4b71Sopenharmony_ci 220e41f4b71Sopenharmony_cioff(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>): void; 221e41f4b71Sopenharmony_ci 222e41f4b71Sopenharmony_ciUnregisters the listener for cached GNSS location reports. 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ci> **NOTE**<br> 225e41f4b71Sopenharmony_ci> This API is supported since API version 8. 226e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('cachedGnssLocationsChange')](js-apis-geoLocationManager.md#geolocationmanageroffcachedgnsslocationschange). 227e41f4b71Sopenharmony_ci 228e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 229e41f4b71Sopenharmony_ci 230e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 231e41f4b71Sopenharmony_ci 232e41f4b71Sopenharmony_ci**Parameters** 233e41f4b71Sopenharmony_ci 234e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 235e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 236e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **cachedGnssLocationsReporting** indicates reporting of cached GNSS locations.| 237e41f4b71Sopenharmony_ci | callback | Callback<Array<[Location](#locationdeprecated)>> | No| Callback to unregister. The callback must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks of the specified event type are unregistered.| 238e41f4b71Sopenharmony_ci 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_ci**Example** 241e41f4b71Sopenharmony_ci 242e41f4b71Sopenharmony_ci ```ts 243e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 244e41f4b71Sopenharmony_ci let cachedLocationsCb = (locations:Array<geolocation.Location>):void => { 245e41f4b71Sopenharmony_ci console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); 246e41f4b71Sopenharmony_ci } 247e41f4b71Sopenharmony_ci let requestInfo:geolocation.CachedGnssLocationsRequest = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true}; 248e41f4b71Sopenharmony_ci geolocation.on('cachedGnssLocationsReporting', requestInfo, cachedLocationsCb); 249e41f4b71Sopenharmony_ci geolocation.off('cachedGnssLocationsReporting'); 250e41f4b71Sopenharmony_ci ``` 251e41f4b71Sopenharmony_ci 252e41f4b71Sopenharmony_ci 253e41f4b71Sopenharmony_ci## geolocation.on('gnssStatusChange')<sup>(deprecated)</sup> 254e41f4b71Sopenharmony_ci 255e41f4b71Sopenharmony_cion(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>): void; 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_ciRegisters a listener for GNSS satellite status change events. This API uses an asynchronous callback to return the result. 258e41f4b71Sopenharmony_ci 259e41f4b71Sopenharmony_ci> **NOTE**<br> 260e41f4b71Sopenharmony_ci> This API is supported since API version 8. 261e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('satelliteStatusChange')](js-apis-geoLocationManager.md#geolocationmanageronsatellitestatuschange). 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_ci**Parameters** 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 270e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 271e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **gnssStatusChange** indicates a GNSS satellite status change.| 272e41f4b71Sopenharmony_ci | callback | Callback<[SatelliteStatusInfo](#satellitestatusinfodeprecated)> | Yes| Callback used to return the result.| 273e41f4b71Sopenharmony_ci 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci**Example** 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ci ```ts 278e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 279e41f4b71Sopenharmony_ci let gnssStatusCb = (satelliteStatusInfo:geolocation.SatelliteStatusInfo):void => { 280e41f4b71Sopenharmony_ci console.log('gnssStatusChange: ' + JSON.stringify(satelliteStatusInfo)); 281e41f4b71Sopenharmony_ci } 282e41f4b71Sopenharmony_ci geolocation.on('gnssStatusChange', gnssStatusCb); 283e41f4b71Sopenharmony_ci ``` 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ci 286e41f4b71Sopenharmony_ci## geolocation.off('gnssStatusChange')<sup>(deprecated)</sup> 287e41f4b71Sopenharmony_ci 288e41f4b71Sopenharmony_cioff(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>): void; 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ciUnregisters the listener for GNSS satellite status change events. 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci> **NOTE**<br> 293e41f4b71Sopenharmony_ci> This API is supported since API version 8. 294e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('satelliteStatusChange')](js-apis-geoLocationManager.md#geolocationmanageroffsatellitestatuschange). 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 297e41f4b71Sopenharmony_ci 298e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ci**Parameters** 301e41f4b71Sopenharmony_ci 302e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 303e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 304e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **gnssStatusChange** indicates a GNSS satellite status change.| 305e41f4b71Sopenharmony_ci | callback | Callback<[SatelliteStatusInfo](#satellitestatusinfodeprecated)> | No| Callback to unregister. The callback must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks of the specified event type are unregistered.| 306e41f4b71Sopenharmony_ci 307e41f4b71Sopenharmony_ci**Example** 308e41f4b71Sopenharmony_ci 309e41f4b71Sopenharmony_ci ```ts 310e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 311e41f4b71Sopenharmony_ci let gnssStatusCb = (satelliteStatusInfo:geolocation.SatelliteStatusInfo) => { 312e41f4b71Sopenharmony_ci console.log('gnssStatusChange: ' + JSON.stringify(satelliteStatusInfo)); 313e41f4b71Sopenharmony_ci } 314e41f4b71Sopenharmony_ci geolocation.on('gnssStatusChange', gnssStatusCb); 315e41f4b71Sopenharmony_ci geolocation.off('gnssStatusChange', gnssStatusCb); 316e41f4b71Sopenharmony_ci ``` 317e41f4b71Sopenharmony_ci 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_ci## geolocation.on('nmeaMessageChange')<sup>(deprecated)</sup> 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_cion(type: 'nmeaMessageChange', callback: Callback<string>): void; 322e41f4b71Sopenharmony_ci 323e41f4b71Sopenharmony_ciRegisters a listener for GNSS NMEA message change events. This API uses an asynchronous callback to return the result. 324e41f4b71Sopenharmony_ci 325e41f4b71Sopenharmony_ci> **NOTE**<br> 326e41f4b71Sopenharmony_ci> This API is supported since API version 8. 327e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('nmeaMessage')](js-apis-geoLocationManager.md#geolocationmanageronnmeamessage). 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 330e41f4b71Sopenharmony_ci 331e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 332e41f4b71Sopenharmony_ci 333e41f4b71Sopenharmony_ci**Parameters** 334e41f4b71Sopenharmony_ci 335e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 336e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 337e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **nmeaMessageChange** indicates a GNSS NMEA message change.| 338e41f4b71Sopenharmony_ci | callback | Callback<string> | Yes| Callback used to return the result.| 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_ci 341e41f4b71Sopenharmony_ci**Example** 342e41f4b71Sopenharmony_ci 343e41f4b71Sopenharmony_ci ```ts 344e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 345e41f4b71Sopenharmony_ci let nmeaCb = (str:string):void => { 346e41f4b71Sopenharmony_ci console.log('nmeaMessageChange: ' + JSON.stringify(str)); 347e41f4b71Sopenharmony_ci } 348e41f4b71Sopenharmony_ci geolocation.on('nmeaMessageChange', nmeaCb ); 349e41f4b71Sopenharmony_ci ``` 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ci 352e41f4b71Sopenharmony_ci## geolocation.off('nmeaMessageChange')<sup>(deprecated)</sup> 353e41f4b71Sopenharmony_ci 354e41f4b71Sopenharmony_cioff(type: 'nmeaMessageChange', callback?: Callback<string>): void; 355e41f4b71Sopenharmony_ci 356e41f4b71Sopenharmony_ciUnregisters the listener for GNSS NMEA message change events. 357e41f4b71Sopenharmony_ci 358e41f4b71Sopenharmony_ci> **NOTE**<br> 359e41f4b71Sopenharmony_ci> This API is supported since API version 8. 360e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('nmeaMessage')](js-apis-geoLocationManager.md#geolocationmanageroffnmeamessage). 361e41f4b71Sopenharmony_ci 362e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 363e41f4b71Sopenharmony_ci 364e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 365e41f4b71Sopenharmony_ci 366e41f4b71Sopenharmony_ci**Parameters** 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 369e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 370e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **nmeaMessageChange** indicates a GNSS NMEA message change.| 371e41f4b71Sopenharmony_ci | callback | Callback<string> | No| Callback to unregister. The callback must be the same as that passed by the **on** API. If this parameter is not specified, all callbacks of the specified event type are unregistered.| 372e41f4b71Sopenharmony_ci 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_ci**Example** 375e41f4b71Sopenharmony_ci 376e41f4b71Sopenharmony_ci ```ts 377e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 378e41f4b71Sopenharmony_ci let nmeaCb = (str:string):void => { 379e41f4b71Sopenharmony_ci console.log('nmeaMessageChange: ' + JSON.stringify(str)); 380e41f4b71Sopenharmony_ci } 381e41f4b71Sopenharmony_ci geolocation.on('nmeaMessageChange', nmeaCb); 382e41f4b71Sopenharmony_ci geolocation.off('nmeaMessageChange', nmeaCb); 383e41f4b71Sopenharmony_ci ``` 384e41f4b71Sopenharmony_ci 385e41f4b71Sopenharmony_ci 386e41f4b71Sopenharmony_ci## geolocation.on('fenceStatusChange')<sup>(deprecated)</sup> 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_cion(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; 389e41f4b71Sopenharmony_ci 390e41f4b71Sopenharmony_ciRegisters a listener for status change events of the specified geofence. This API uses an asynchronous callback to return the result. 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci> **NOTE**<br> 393e41f4b71Sopenharmony_ci> This API is supported since API version 8. 394e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('gnssFenceStatusChange')](js-apis-geoLocationManager.md#geolocationmanagerongnssfencestatuschange). 395e41f4b71Sopenharmony_ci 396e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 397e41f4b71Sopenharmony_ci 398e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geofence 399e41f4b71Sopenharmony_ci 400e41f4b71Sopenharmony_ci**Parameters** 401e41f4b71Sopenharmony_ci 402e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 403e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 404e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **fenceStatusChange** indicates a geofence status change.| 405e41f4b71Sopenharmony_ci | request | [GeofenceRequest](#geofencerequestdeprecated) | Yes| Geofencing request.| 406e41f4b71Sopenharmony_ci | want | [WantAgent](../apis-ability-kit/js-apis-app-ability-wantAgent.md) | Yes| **WantAgent** used to receive geofence (entrance or exit) events.| 407e41f4b71Sopenharmony_ci 408e41f4b71Sopenharmony_ci**Example** 409e41f4b71Sopenharmony_ci 410e41f4b71Sopenharmony_ci ```ts 411e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 412e41f4b71Sopenharmony_ci import wantAgent from '@ohos.app.ability.wantAgent'; 413e41f4b71Sopenharmony_ci 414e41f4b71Sopenharmony_ci let wantAgentInfo:wantAgent.WantAgentInfo = { 415e41f4b71Sopenharmony_ci wants: [ 416e41f4b71Sopenharmony_ci { 417e41f4b71Sopenharmony_ci bundleName: "com.example.myapplication", 418e41f4b71Sopenharmony_ci abilityName: "EntryAbility", 419e41f4b71Sopenharmony_ci action: "action1" 420e41f4b71Sopenharmony_ci } 421e41f4b71Sopenharmony_ci ], 422e41f4b71Sopenharmony_ci operationType: wantAgent.OperationType.START_ABILITY, 423e41f4b71Sopenharmony_ci requestCode: 0, 424e41f4b71Sopenharmony_ci wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG], 425e41f4b71Sopenharmony_ci }; 426e41f4b71Sopenharmony_ci 427e41f4b71Sopenharmony_ci wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { 428e41f4b71Sopenharmony_ci let requestInfo:geolocation.GeofenceRequest = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 31.12, "longitude": 121.11, "radius": 100, "expiration": 10000}}; 429e41f4b71Sopenharmony_ci geolocation.on('fenceStatusChange', requestInfo, wantAgentObj); 430e41f4b71Sopenharmony_ci }); 431e41f4b71Sopenharmony_ci ``` 432e41f4b71Sopenharmony_ci 433e41f4b71Sopenharmony_ci 434e41f4b71Sopenharmony_ci## geolocation.off('fenceStatusChange')<sup>(deprecated)</sup> 435e41f4b71Sopenharmony_ci 436e41f4b71Sopenharmony_cioff(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; 437e41f4b71Sopenharmony_ci 438e41f4b71Sopenharmony_ciUnregisters the listener for status change events of the specified geofence. 439e41f4b71Sopenharmony_ci 440e41f4b71Sopenharmony_ci> **NOTE**<br> 441e41f4b71Sopenharmony_ci> This API is supported since API version 8. 442e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('gnssFenceStatusChange')](js-apis-geoLocationManager.md#geolocationmanageroffgnssfencestatuschange). 443e41f4b71Sopenharmony_ci 444e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 445e41f4b71Sopenharmony_ci 446e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geofence 447e41f4b71Sopenharmony_ci 448e41f4b71Sopenharmony_ci**Parameters** 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 451e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 452e41f4b71Sopenharmony_ci | type | string | Yes| Event type. The value **fenceStatusChange** indicates a geofence status change.| 453e41f4b71Sopenharmony_ci | request | [GeofenceRequest](#geofencerequestdeprecated) | Yes| Geofencing request.| 454e41f4b71Sopenharmony_ci | want | [WantAgent](../apis-ability-kit/js-apis-app-ability-wantAgent.md) | Yes| **WantAgent** used to receive geofence (entrance or exit) events.| 455e41f4b71Sopenharmony_ci 456e41f4b71Sopenharmony_ci**Example** 457e41f4b71Sopenharmony_ci 458e41f4b71Sopenharmony_ci ```ts 459e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 460e41f4b71Sopenharmony_ci import wantAgent from '@ohos.app.ability.wantAgent'; 461e41f4b71Sopenharmony_ci 462e41f4b71Sopenharmony_ci let wantAgentInfo:wantAgent.WantAgentInfo = { 463e41f4b71Sopenharmony_ci wants: [ 464e41f4b71Sopenharmony_ci { 465e41f4b71Sopenharmony_ci bundleName: "com.example.myapplication", 466e41f4b71Sopenharmony_ci abilityName: "EntryAbility", 467e41f4b71Sopenharmony_ci action: "action1", 468e41f4b71Sopenharmony_ci } 469e41f4b71Sopenharmony_ci ], 470e41f4b71Sopenharmony_ci operationType: wantAgent.OperationType.START_ABILITY, 471e41f4b71Sopenharmony_ci requestCode: 0, 472e41f4b71Sopenharmony_ci wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] 473e41f4b71Sopenharmony_ci }; 474e41f4b71Sopenharmony_ci 475e41f4b71Sopenharmony_ci wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { 476e41f4b71Sopenharmony_ci let requestInfo:geolocation.GeofenceRequest = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 31.12, "longitude": 121.11, "radius": 100, "expiration": 10000}}; 477e41f4b71Sopenharmony_ci geolocation.on('fenceStatusChange', requestInfo, wantAgentObj); 478e41f4b71Sopenharmony_ci geolocation.off('fenceStatusChange', requestInfo, wantAgentObj); 479e41f4b71Sopenharmony_ci }); 480e41f4b71Sopenharmony_ci ``` 481e41f4b71Sopenharmony_ci 482e41f4b71Sopenharmony_ci 483e41f4b71Sopenharmony_ci## geolocation.getCurrentLocation<sup>(deprecated)</sup> 484e41f4b71Sopenharmony_ci 485e41f4b71Sopenharmony_cigetCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>): void 486e41f4b71Sopenharmony_ci 487e41f4b71Sopenharmony_ciObtains the current position. This API uses an asynchronous callback to return the result. 488e41f4b71Sopenharmony_ci 489e41f4b71Sopenharmony_ci> **NOTE**<br> 490e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation). 491e41f4b71Sopenharmony_ci 492e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 495e41f4b71Sopenharmony_ci 496e41f4b71Sopenharmony_ci**Parameters** 497e41f4b71Sopenharmony_ci 498e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 499e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 500e41f4b71Sopenharmony_ci | request | [CurrentLocationRequest](#currentlocationrequestdeprecated) | Yes| Location request.| 501e41f4b71Sopenharmony_ci | callback | AsyncCallback<[Location](#locationdeprecated)> | Yes| Callback used to return the result.| 502e41f4b71Sopenharmony_ci 503e41f4b71Sopenharmony_ci**Example** 504e41f4b71Sopenharmony_ci 505e41f4b71Sopenharmony_ci ```ts 506e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 507e41f4b71Sopenharmony_ci import BusinessError from "@ohos.base" 508e41f4b71Sopenharmony_ci let requestInfo:geolocation.CurrentLocationRequest = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; 509e41f4b71Sopenharmony_ci let locationChange = (err:BusinessError.BusinessError, location:geolocation.Location) => { 510e41f4b71Sopenharmony_ci if (err) { 511e41f4b71Sopenharmony_ci console.log('locationChanger: err=' + JSON.stringify(err)); 512e41f4b71Sopenharmony_ci } 513e41f4b71Sopenharmony_ci if (location) { 514e41f4b71Sopenharmony_ci console.log('locationChanger: location=' + JSON.stringify(location)); 515e41f4b71Sopenharmony_ci } 516e41f4b71Sopenharmony_ci }; 517e41f4b71Sopenharmony_ci geolocation.getCurrentLocation(requestInfo, locationChange); 518e41f4b71Sopenharmony_ci ``` 519e41f4b71Sopenharmony_ci 520e41f4b71Sopenharmony_ci 521e41f4b71Sopenharmony_ci## geolocation.getCurrentLocation<sup>(deprecated)</sup> 522e41f4b71Sopenharmony_ci 523e41f4b71Sopenharmony_cigetCurrentLocation(callback: AsyncCallback<Location>): void 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ci 526e41f4b71Sopenharmony_ciObtains the current position. This API uses an asynchronous callback to return the result. 527e41f4b71Sopenharmony_ci 528e41f4b71Sopenharmony_ci> **NOTE**<br> 529e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation). 530e41f4b71Sopenharmony_ci 531e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 532e41f4b71Sopenharmony_ci 533e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 534e41f4b71Sopenharmony_ci 535e41f4b71Sopenharmony_ci**Parameters** 536e41f4b71Sopenharmony_ci 537e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 538e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 539e41f4b71Sopenharmony_ci | callback | AsyncCallback<[Location](#locationdeprecated)> | Yes| Callback used to return the result.| 540e41f4b71Sopenharmony_ci 541e41f4b71Sopenharmony_ci**Example** 542e41f4b71Sopenharmony_ci 543e41f4b71Sopenharmony_ci ```ts 544e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 545e41f4b71Sopenharmony_ci import BusinessError from "@ohos.base" 546e41f4b71Sopenharmony_ci let locationChange = (err:BusinessError.BusinessError, location:geolocation.Location):void => { 547e41f4b71Sopenharmony_ci if (err) { 548e41f4b71Sopenharmony_ci console.log('locationChanger: err=' + JSON.stringify(err)); 549e41f4b71Sopenharmony_ci } 550e41f4b71Sopenharmony_ci if (location) { 551e41f4b71Sopenharmony_ci console.log('locationChanger: location=' + JSON.stringify(location)); 552e41f4b71Sopenharmony_ci } 553e41f4b71Sopenharmony_ci }; 554e41f4b71Sopenharmony_ci geolocation.getCurrentLocation(locationChange); 555e41f4b71Sopenharmony_ci ``` 556e41f4b71Sopenharmony_ci 557e41f4b71Sopenharmony_ci 558e41f4b71Sopenharmony_ci## geolocation.getCurrentLocation<sup>(deprecated)</sup> 559e41f4b71Sopenharmony_ci 560e41f4b71Sopenharmony_cigetCurrentLocation(request?: CurrentLocationRequest): Promise<Location> 561e41f4b71Sopenharmony_ci 562e41f4b71Sopenharmony_ciObtains the current position. This API uses a promise to return the result. 563e41f4b71Sopenharmony_ci 564e41f4b71Sopenharmony_ci> **NOTE**<br> 565e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation-2). 566e41f4b71Sopenharmony_ci 567e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 568e41f4b71Sopenharmony_ci 569e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 570e41f4b71Sopenharmony_ci 571e41f4b71Sopenharmony_ci**Parameters** 572e41f4b71Sopenharmony_ci 573e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 574e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 575e41f4b71Sopenharmony_ci | request | [CurrentLocationRequest](#currentlocationrequestdeprecated) | No| Location request.| 576e41f4b71Sopenharmony_ci 577e41f4b71Sopenharmony_ci**Return value** 578e41f4b71Sopenharmony_ci 579e41f4b71Sopenharmony_ci | Type| Description| 580e41f4b71Sopenharmony_ci | -------- | -------- | 581e41f4b71Sopenharmony_ci | Promise<[Location](#locationdeprecated)> | Promise used to return the result.| 582e41f4b71Sopenharmony_ci 583e41f4b71Sopenharmony_ci 584e41f4b71Sopenharmony_ci**Example** 585e41f4b71Sopenharmony_ci 586e41f4b71Sopenharmony_ci ```ts 587e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 588e41f4b71Sopenharmony_ci let requestInfo:geolocation.CurrentLocationRequest = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; 589e41f4b71Sopenharmony_ci geolocation.getCurrentLocation(requestInfo).then((result) => { 590e41f4b71Sopenharmony_ci console.log('current location: ' + JSON.stringify(result)); 591e41f4b71Sopenharmony_ci }); 592e41f4b71Sopenharmony_ci ``` 593e41f4b71Sopenharmony_ci 594e41f4b71Sopenharmony_ci 595e41f4b71Sopenharmony_ci## geolocation.getLastLocation<sup>(deprecated)</sup> 596e41f4b71Sopenharmony_ci 597e41f4b71Sopenharmony_cigetLastLocation(callback: AsyncCallback<Location>): void 598e41f4b71Sopenharmony_ci 599e41f4b71Sopenharmony_ciObtains the previous location. This API uses an asynchronous callback to return the result. 600e41f4b71Sopenharmony_ci 601e41f4b71Sopenharmony_ci> **NOTE**<br> 602e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getLastLocation](js-apis-geoLocationManager.md#geolocationmanagergetlastlocation). 603e41f4b71Sopenharmony_ci 604e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 605e41f4b71Sopenharmony_ci 606e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 607e41f4b71Sopenharmony_ci 608e41f4b71Sopenharmony_ci**Parameters** 609e41f4b71Sopenharmony_ci 610e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 611e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 612e41f4b71Sopenharmony_ci | callback | AsyncCallback<[Location](#locationdeprecated)> | Yes| Callback used to return the result.| 613e41f4b71Sopenharmony_ci 614e41f4b71Sopenharmony_ci 615e41f4b71Sopenharmony_ci**Example** 616e41f4b71Sopenharmony_ci 617e41f4b71Sopenharmony_ci ```ts 618e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 619e41f4b71Sopenharmony_ci geolocation.getLastLocation((err, data) => { 620e41f4b71Sopenharmony_ci if (err) { 621e41f4b71Sopenharmony_ci console.log('getLastLocation: err=' + JSON.stringify(err)); 622e41f4b71Sopenharmony_ci } 623e41f4b71Sopenharmony_ci if (data) { 624e41f4b71Sopenharmony_ci console.log('getLastLocation: data=' + JSON.stringify(data)); 625e41f4b71Sopenharmony_ci } 626e41f4b71Sopenharmony_ci }); 627e41f4b71Sopenharmony_ci ``` 628e41f4b71Sopenharmony_ci 629e41f4b71Sopenharmony_ci 630e41f4b71Sopenharmony_ci## geolocation.getLastLocation<sup>(deprecated)</sup> 631e41f4b71Sopenharmony_ci 632e41f4b71Sopenharmony_cigetLastLocation(): Promise<Location> 633e41f4b71Sopenharmony_ci 634e41f4b71Sopenharmony_ciObtains the previous location. This API uses a promise to return the result. 635e41f4b71Sopenharmony_ci 636e41f4b71Sopenharmony_ci> **NOTE**<br> 637e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getLastLocation](js-apis-geoLocationManager.md#geolocationmanagergetlastlocation). 638e41f4b71Sopenharmony_ci 639e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 640e41f4b71Sopenharmony_ci 641e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 642e41f4b71Sopenharmony_ci 643e41f4b71Sopenharmony_ci**Return value** 644e41f4b71Sopenharmony_ci 645e41f4b71Sopenharmony_ci | Type| Description| 646e41f4b71Sopenharmony_ci | -------- | -------- | 647e41f4b71Sopenharmony_ci | Promise<[Location](#locationdeprecated)> | Promise used to return the result.| 648e41f4b71Sopenharmony_ci 649e41f4b71Sopenharmony_ci 650e41f4b71Sopenharmony_ci**Example** 651e41f4b71Sopenharmony_ci 652e41f4b71Sopenharmony_ci ```ts 653e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 654e41f4b71Sopenharmony_ci geolocation.getLastLocation().then((result) => { 655e41f4b71Sopenharmony_ci console.log('getLastLocation: result: ' + JSON.stringify(result)); 656e41f4b71Sopenharmony_ci }); 657e41f4b71Sopenharmony_ci ``` 658e41f4b71Sopenharmony_ci 659e41f4b71Sopenharmony_ci 660e41f4b71Sopenharmony_ci## geolocation.isLocationEnabled<sup>(deprecated)</sup> 661e41f4b71Sopenharmony_ci 662e41f4b71Sopenharmony_ciisLocationEnabled(callback: AsyncCallback<boolean>): void 663e41f4b71Sopenharmony_ci 664e41f4b71Sopenharmony_ciChecks whether the location service is enabled. This API uses an asynchronous callback to return the result. 665e41f4b71Sopenharmony_ci 666e41f4b71Sopenharmony_ci> **NOTE**<br> 667e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isLocationEnabled](js-apis-geoLocationManager.md#geolocationmanagerislocationenabled). 668e41f4b71Sopenharmony_ci 669e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 670e41f4b71Sopenharmony_ci 671e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 672e41f4b71Sopenharmony_ci 673e41f4b71Sopenharmony_ci**Parameters** 674e41f4b71Sopenharmony_ci 675e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 676e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 677e41f4b71Sopenharmony_ci | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. The value **true** indicates that the location service is enabled, and the value **false** indicates the opposite.| 678e41f4b71Sopenharmony_ci 679e41f4b71Sopenharmony_ci**Example** 680e41f4b71Sopenharmony_ci 681e41f4b71Sopenharmony_ci ```ts 682e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 683e41f4b71Sopenharmony_ci geolocation.isLocationEnabled((err, data) => { 684e41f4b71Sopenharmony_ci if (err) { 685e41f4b71Sopenharmony_ci console.log('isLocationEnabled: err=' + JSON.stringify(err)); 686e41f4b71Sopenharmony_ci } 687e41f4b71Sopenharmony_ci if (data) { 688e41f4b71Sopenharmony_ci console.log('isLocationEnabled: data=' + JSON.stringify(data)); 689e41f4b71Sopenharmony_ci } 690e41f4b71Sopenharmony_ci }); 691e41f4b71Sopenharmony_ci ``` 692e41f4b71Sopenharmony_ci 693e41f4b71Sopenharmony_ci 694e41f4b71Sopenharmony_ci## geolocation.isLocationEnabled<sup>(deprecated)</sup> 695e41f4b71Sopenharmony_ci 696e41f4b71Sopenharmony_ciisLocationEnabled(): Promise<boolean> 697e41f4b71Sopenharmony_ci 698e41f4b71Sopenharmony_ciChecks whether the location service is enabled. This API uses a promise to return the result. 699e41f4b71Sopenharmony_ci 700e41f4b71Sopenharmony_ci> **NOTE**<br> 701e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isLocationEnabled](js-apis-geoLocationManager.md#geolocationmanagerislocationenabled). 702e41f4b71Sopenharmony_ci 703e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 704e41f4b71Sopenharmony_ci 705e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 706e41f4b71Sopenharmony_ci 707e41f4b71Sopenharmony_ci**Return value** 708e41f4b71Sopenharmony_ci 709e41f4b71Sopenharmony_ci | Type| Description| 710e41f4b71Sopenharmony_ci | -------- | -------- | 711e41f4b71Sopenharmony_ci | Promise<boolean> | Promise used to return the result. The value **true** indicates that the location service is enabled, and the value **false** indicates the opposite.| 712e41f4b71Sopenharmony_ci 713e41f4b71Sopenharmony_ci**Example** 714e41f4b71Sopenharmony_ci 715e41f4b71Sopenharmony_ci ```ts 716e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 717e41f4b71Sopenharmony_ci geolocation.isLocationEnabled().then((result) => { 718e41f4b71Sopenharmony_ci console.log('promise, isLocationEnabled: ' + JSON.stringify(result)); 719e41f4b71Sopenharmony_ci }); 720e41f4b71Sopenharmony_ci ``` 721e41f4b71Sopenharmony_ci 722e41f4b71Sopenharmony_ci 723e41f4b71Sopenharmony_ci## geolocation.requestEnableLocation<sup>(deprecated)</sup> 724e41f4b71Sopenharmony_ci 725e41f4b71Sopenharmony_cirequestEnableLocation(callback: AsyncCallback<boolean>): void 726e41f4b71Sopenharmony_ci 727e41f4b71Sopenharmony_ciSends a request for enabling the location service. This API uses an asynchronous callback to return the result. 728e41f4b71Sopenharmony_ci 729e41f4b71Sopenharmony_ci> **NOTE**<br> 730e41f4b71Sopenharmony_ci> This API has been discarded since API version 9. It is recommended that a dialog box be displayed in the application to request the user to go to Settings to enable the location function and specify the scenarios in which the location information will be used in the dialog box. 731e41f4b71Sopenharmony_ci 732e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 733e41f4b71Sopenharmony_ci 734e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 735e41f4b71Sopenharmony_ci 736e41f4b71Sopenharmony_ci**Parameters** 737e41f4b71Sopenharmony_ci 738e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 739e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 740e41f4b71Sopenharmony_ci | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. The value **true** indicates that the location service is enabled, and the value **false** indicates the opposite.| 741e41f4b71Sopenharmony_ci 742e41f4b71Sopenharmony_ci**Example** 743e41f4b71Sopenharmony_ci 744e41f4b71Sopenharmony_ci ```ts 745e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 746e41f4b71Sopenharmony_ci geolocation.requestEnableLocation((err, data) => { 747e41f4b71Sopenharmony_ci if (err) { 748e41f4b71Sopenharmony_ci console.log('requestEnableLocation: err=' + JSON.stringify(err)); 749e41f4b71Sopenharmony_ci } 750e41f4b71Sopenharmony_ci if (data) { 751e41f4b71Sopenharmony_ci console.log('requestEnableLocation: data=' + JSON.stringify(data)); 752e41f4b71Sopenharmony_ci } 753e41f4b71Sopenharmony_ci }); 754e41f4b71Sopenharmony_ci ``` 755e41f4b71Sopenharmony_ci 756e41f4b71Sopenharmony_ci 757e41f4b71Sopenharmony_ci## geolocation.requestEnableLocation<sup>(deprecated)</sup> 758e41f4b71Sopenharmony_ci 759e41f4b71Sopenharmony_cirequestEnableLocation(): Promise<boolean> 760e41f4b71Sopenharmony_ci 761e41f4b71Sopenharmony_ciSends a request for enabling the location service. This API uses a promise to return the result. 762e41f4b71Sopenharmony_ci 763e41f4b71Sopenharmony_ci> **NOTE**<br> 764e41f4b71Sopenharmony_ci> This API has been discarded since API version 9. It is recommended that a dialog box be displayed in the application to request the user to go to Settings to enable the location function and specify the scenarios in which the location information will be used in the dialog box. 765e41f4b71Sopenharmony_ci 766e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 767e41f4b71Sopenharmony_ci 768e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 769e41f4b71Sopenharmony_ci 770e41f4b71Sopenharmony_ci**Return value** 771e41f4b71Sopenharmony_ci 772e41f4b71Sopenharmony_ci | Type| Description| 773e41f4b71Sopenharmony_ci | -------- | -------- | 774e41f4b71Sopenharmony_ci | Promise<boolean> | Promise used to return the result. The value **true** indicates that the location service is enabled, and the value **false** indicates the opposite.| 775e41f4b71Sopenharmony_ci 776e41f4b71Sopenharmony_ci**Example** 777e41f4b71Sopenharmony_ci 778e41f4b71Sopenharmony_ci ```ts 779e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 780e41f4b71Sopenharmony_ci geolocation.requestEnableLocation().then((result) => { 781e41f4b71Sopenharmony_ci console.log('promise, requestEnableLocation: ' + JSON.stringify(result)); 782e41f4b71Sopenharmony_ci }); 783e41f4b71Sopenharmony_ci ``` 784e41f4b71Sopenharmony_ci 785e41f4b71Sopenharmony_ci 786e41f4b71Sopenharmony_ci## geolocation.isGeoServiceAvailable<sup>(deprecated)</sup> 787e41f4b71Sopenharmony_ci 788e41f4b71Sopenharmony_ciisGeoServiceAvailable(callback: AsyncCallback<boolean>): void 789e41f4b71Sopenharmony_ci 790e41f4b71Sopenharmony_ciChecks whether the (reverse) geocoding service is available. This API uses an asynchronous callback to return the result. 791e41f4b71Sopenharmony_ci 792e41f4b71Sopenharmony_ci> **NOTE**<br> 793e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isGeocoderAvailable](js-apis-geoLocationManager.md#geolocationmanagerisgeocoderavailable). 794e41f4b71Sopenharmony_ci 795e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 796e41f4b71Sopenharmony_ci 797e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geocoder 798e41f4b71Sopenharmony_ci 799e41f4b71Sopenharmony_ci**Parameters** 800e41f4b71Sopenharmony_ci 801e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 802e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 803e41f4b71Sopenharmony_ci | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. The value **true** indicates that the (reverse) geocoding service is available, and the value **false** indicates the opposite.| 804e41f4b71Sopenharmony_ci 805e41f4b71Sopenharmony_ci**Example** 806e41f4b71Sopenharmony_ci 807e41f4b71Sopenharmony_ci ```ts 808e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 809e41f4b71Sopenharmony_ci geolocation.isGeoServiceAvailable((err, data) => { 810e41f4b71Sopenharmony_ci if (err) { 811e41f4b71Sopenharmony_ci console.log('isGeoServiceAvailable: err=' + JSON.stringify(err)); 812e41f4b71Sopenharmony_ci } 813e41f4b71Sopenharmony_ci if (data) { 814e41f4b71Sopenharmony_ci console.log('isGeoServiceAvailable: data=' + JSON.stringify(data)); 815e41f4b71Sopenharmony_ci } 816e41f4b71Sopenharmony_ci }); 817e41f4b71Sopenharmony_ci ``` 818e41f4b71Sopenharmony_ci 819e41f4b71Sopenharmony_ci 820e41f4b71Sopenharmony_ci## geolocation.isGeoServiceAvailable<sup>(deprecated)</sup> 821e41f4b71Sopenharmony_ci 822e41f4b71Sopenharmony_ciisGeoServiceAvailable(): Promise<boolean> 823e41f4b71Sopenharmony_ci 824e41f4b71Sopenharmony_ciChecks whether the (reverse) geocoding service is available. This API uses a promise to return the result. 825e41f4b71Sopenharmony_ci 826e41f4b71Sopenharmony_ci> **NOTE**<br> 827e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isGeocoderAvailable](js-apis-geoLocationManager.md#geolocationmanagerisgeocoderavailable). 828e41f4b71Sopenharmony_ci 829e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 830e41f4b71Sopenharmony_ci 831e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geocoder 832e41f4b71Sopenharmony_ci 833e41f4b71Sopenharmony_ci**Return value** 834e41f4b71Sopenharmony_ci 835e41f4b71Sopenharmony_ci | Type| Description| 836e41f4b71Sopenharmony_ci | -------- | -------- | 837e41f4b71Sopenharmony_ci | Promise<boolean> | Promise used to return the result. The value **true** indicates that the (reverse) geocoding service is available, and the value **false** indicates the opposite.| 838e41f4b71Sopenharmony_ci 839e41f4b71Sopenharmony_ci**Example** 840e41f4b71Sopenharmony_ci 841e41f4b71Sopenharmony_ci ```ts 842e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 843e41f4b71Sopenharmony_ci geolocation.isGeoServiceAvailable().then((result) => { 844e41f4b71Sopenharmony_ci console.log('promise, isGeoServiceAvailable: ' + JSON.stringify(result)); 845e41f4b71Sopenharmony_ci }); 846e41f4b71Sopenharmony_ci ``` 847e41f4b71Sopenharmony_ci 848e41f4b71Sopenharmony_ci 849e41f4b71Sopenharmony_ci## geolocation.getAddressesFromLocation<sup>(deprecated)</sup> 850e41f4b71Sopenharmony_ci 851e41f4b71Sopenharmony_cigetAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void 852e41f4b71Sopenharmony_ci 853e41f4b71Sopenharmony_ciConverts coordinates into geographic descriptions through reverse geocoding. This API uses an asynchronous callback to return the result. 854e41f4b71Sopenharmony_ci 855e41f4b71Sopenharmony_ci> **NOTE**<br> 856e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocation](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocation). 857e41f4b71Sopenharmony_ci 858e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 859e41f4b71Sopenharmony_ci 860e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geocoder 861e41f4b71Sopenharmony_ci 862e41f4b71Sopenharmony_ci**Parameters** 863e41f4b71Sopenharmony_ci 864e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 865e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 866e41f4b71Sopenharmony_ci | request | [ReverseGeoCodeRequest](#reversegeocoderequestdeprecated) | Yes| Reverse geocoding request.| 867e41f4b71Sopenharmony_ci | callback | AsyncCallback<Array<[GeoAddress](#geoaddressdeprecated)>> | Yes| Callback used to return the result.| 868e41f4b71Sopenharmony_ci 869e41f4b71Sopenharmony_ci**Example** 870e41f4b71Sopenharmony_ci 871e41f4b71Sopenharmony_ci ```ts 872e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 873e41f4b71Sopenharmony_ci let reverseGeocodeRequest:geolocation.ReverseGeoCodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; 874e41f4b71Sopenharmony_ci geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { 875e41f4b71Sopenharmony_ci if (err) { 876e41f4b71Sopenharmony_ci console.log('getAddressesFromLocation: err=' + JSON.stringify(err)); 877e41f4b71Sopenharmony_ci } 878e41f4b71Sopenharmony_ci if (data) { 879e41f4b71Sopenharmony_ci console.log('getAddressesFromLocation: data=' + JSON.stringify(data)); 880e41f4b71Sopenharmony_ci } 881e41f4b71Sopenharmony_ci }); 882e41f4b71Sopenharmony_ci ``` 883e41f4b71Sopenharmony_ci 884e41f4b71Sopenharmony_ci 885e41f4b71Sopenharmony_ci## geolocation.getAddressesFromLocation<sup>(deprecated)</sup> 886e41f4b71Sopenharmony_ci 887e41f4b71Sopenharmony_cigetAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<GeoAddress>>; 888e41f4b71Sopenharmony_ci 889e41f4b71Sopenharmony_ciConverts coordinates into geographic descriptions through reverse geocoding. This API uses a promise to return the result. 890e41f4b71Sopenharmony_ci 891e41f4b71Sopenharmony_ci> **NOTE**<br> 892e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocation](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocation-1). 893e41f4b71Sopenharmony_ci 894e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 895e41f4b71Sopenharmony_ci 896e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geocoder 897e41f4b71Sopenharmony_ci 898e41f4b71Sopenharmony_ci**Parameters** 899e41f4b71Sopenharmony_ci 900e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 901e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 902e41f4b71Sopenharmony_ci | request | [ReverseGeoCodeRequest](#reversegeocoderequestdeprecated) | Yes| Reverse geocoding request.| 903e41f4b71Sopenharmony_ci 904e41f4b71Sopenharmony_ci**Return value** 905e41f4b71Sopenharmony_ci 906e41f4b71Sopenharmony_ci | Type| Description| 907e41f4b71Sopenharmony_ci | -------- | -------- | 908e41f4b71Sopenharmony_ci | Promise<Array<[GeoAddress](#geoaddressdeprecated)>> | Promise used to return the result.| 909e41f4b71Sopenharmony_ci 910e41f4b71Sopenharmony_ci**Example** 911e41f4b71Sopenharmony_ci 912e41f4b71Sopenharmony_ci ```ts 913e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 914e41f4b71Sopenharmony_ci let reverseGeocodeRequest:geolocation.ReverseGeoCodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; 915e41f4b71Sopenharmony_ci geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { 916e41f4b71Sopenharmony_ci console.log('getAddressesFromLocation: ' + JSON.stringify(data)); 917e41f4b71Sopenharmony_ci }); 918e41f4b71Sopenharmony_ci ``` 919e41f4b71Sopenharmony_ci 920e41f4b71Sopenharmony_ci 921e41f4b71Sopenharmony_ci## geolocation.getAddressesFromLocationName<sup>(deprecated)</sup> 922e41f4b71Sopenharmony_ci 923e41f4b71Sopenharmony_cigetAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void 924e41f4b71Sopenharmony_ci 925e41f4b71Sopenharmony_ciConverts geographic descriptions into coordinates through geocoding. This API uses an asynchronous callback to return the result. 926e41f4b71Sopenharmony_ci 927e41f4b71Sopenharmony_ci> **NOTE**<br> 928e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocationName](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocationname). 929e41f4b71Sopenharmony_ci 930e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 931e41f4b71Sopenharmony_ci 932e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geocoder 933e41f4b71Sopenharmony_ci 934e41f4b71Sopenharmony_ci**Parameters** 935e41f4b71Sopenharmony_ci 936e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 937e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 938e41f4b71Sopenharmony_ci | request | [GeoCodeRequest](#geocoderequestdeprecated) | Yes| Geocoding request.| 939e41f4b71Sopenharmony_ci | callback | AsyncCallback<Array<[GeoAddress](#geoaddressdeprecated)>> | Yes| Callback used to return the result.| 940e41f4b71Sopenharmony_ci 941e41f4b71Sopenharmony_ci**Example** 942e41f4b71Sopenharmony_ci 943e41f4b71Sopenharmony_ci ```ts 944e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 945e41f4b71Sopenharmony_ci let geocodeRequest:geolocation.GeoCodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1}; 946e41f4b71Sopenharmony_ci geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => { 947e41f4b71Sopenharmony_ci if (err) { 948e41f4b71Sopenharmony_ci console.log('getAddressesFromLocationName: err=' + JSON.stringify(err)); 949e41f4b71Sopenharmony_ci } 950e41f4b71Sopenharmony_ci if (data) { 951e41f4b71Sopenharmony_ci console.log('getAddressesFromLocationName: data=' + JSON.stringify(data)); 952e41f4b71Sopenharmony_ci } 953e41f4b71Sopenharmony_ci }); 954e41f4b71Sopenharmony_ci ``` 955e41f4b71Sopenharmony_ci 956e41f4b71Sopenharmony_ci 957e41f4b71Sopenharmony_ci## geolocation.getAddressesFromLocationName<sup>(deprecated)</sup> 958e41f4b71Sopenharmony_ci 959e41f4b71Sopenharmony_cigetAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAddress>> 960e41f4b71Sopenharmony_ci 961e41f4b71Sopenharmony_ciConverts geographic descriptions into coordinates through geocoding. This API uses a promise to return the result. 962e41f4b71Sopenharmony_ci 963e41f4b71Sopenharmony_ci> **NOTE**<br> 964e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocationName](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocationname-1). 965e41f4b71Sopenharmony_ci 966e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 967e41f4b71Sopenharmony_ci 968e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geocoder 969e41f4b71Sopenharmony_ci 970e41f4b71Sopenharmony_ci**Parameters** 971e41f4b71Sopenharmony_ci 972e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 973e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 974e41f4b71Sopenharmony_ci | request | [GeoCodeRequest](#geocoderequestdeprecated) | Yes| Geocoding request.| 975e41f4b71Sopenharmony_ci 976e41f4b71Sopenharmony_ci**Return value** 977e41f4b71Sopenharmony_ci 978e41f4b71Sopenharmony_ci | Type| Description| 979e41f4b71Sopenharmony_ci | -------- | -------- | 980e41f4b71Sopenharmony_ci | Promise<Array<[GeoAddress](#geoaddressdeprecated)>> | Promise used to return the result.| 981e41f4b71Sopenharmony_ci 982e41f4b71Sopenharmony_ci**Example** 983e41f4b71Sopenharmony_ci 984e41f4b71Sopenharmony_ci ```ts 985e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 986e41f4b71Sopenharmony_ci let geocodeRequest:geolocation.GeoCodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1}; 987e41f4b71Sopenharmony_ci geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { 988e41f4b71Sopenharmony_ci console.log('getAddressesFromLocationName: ' + JSON.stringify(result)); 989e41f4b71Sopenharmony_ci }); 990e41f4b71Sopenharmony_ci ``` 991e41f4b71Sopenharmony_ci 992e41f4b71Sopenharmony_ci 993e41f4b71Sopenharmony_ci## geolocation.getCachedGnssLocationsSize<sup>(deprecated)</sup> 994e41f4b71Sopenharmony_ci 995e41f4b71Sopenharmony_cigetCachedGnssLocationsSize(callback: AsyncCallback<number>): void; 996e41f4b71Sopenharmony_ci 997e41f4b71Sopenharmony_ciObtains the number of cached GNSS locations. This API uses an asynchronous callback to return the result. 998e41f4b71Sopenharmony_ci 999e41f4b71Sopenharmony_ci> **NOTE**<br> 1000e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1001e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCachedGnssLocationsSize](js-apis-geoLocationManager.md#geolocationmanagergetcachedgnsslocationssize). 1002e41f4b71Sopenharmony_ci 1003e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1004e41f4b71Sopenharmony_ci 1005e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 1006e41f4b71Sopenharmony_ci 1007e41f4b71Sopenharmony_ci**Parameters** 1008e41f4b71Sopenharmony_ci 1009e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 1010e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 1011e41f4b71Sopenharmony_ci | callback | AsyncCallback<number> | Yes| Callback used to return the result.| 1012e41f4b71Sopenharmony_ci 1013e41f4b71Sopenharmony_ci**Example** 1014e41f4b71Sopenharmony_ci 1015e41f4b71Sopenharmony_ci ```ts 1016e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 1017e41f4b71Sopenharmony_ci geolocation.getCachedGnssLocationsSize((err, size) => { 1018e41f4b71Sopenharmony_ci if (err) { 1019e41f4b71Sopenharmony_ci console.log('getCachedGnssLocationsSize: err=' + JSON.stringify(err)); 1020e41f4b71Sopenharmony_ci } 1021e41f4b71Sopenharmony_ci if (size) { 1022e41f4b71Sopenharmony_ci console.log('getCachedGnssLocationsSize: size=' + JSON.stringify(size)); 1023e41f4b71Sopenharmony_ci } 1024e41f4b71Sopenharmony_ci }); 1025e41f4b71Sopenharmony_ci ``` 1026e41f4b71Sopenharmony_ci 1027e41f4b71Sopenharmony_ci 1028e41f4b71Sopenharmony_ci## geolocation.getCachedGnssLocationsSize<sup>(deprecated)</sup> 1029e41f4b71Sopenharmony_ci 1030e41f4b71Sopenharmony_cigetCachedGnssLocationsSize(): Promise<number>; 1031e41f4b71Sopenharmony_ci 1032e41f4b71Sopenharmony_ciObtains the number of cached GNSS locations. This API uses a promise to return the result. 1033e41f4b71Sopenharmony_ci 1034e41f4b71Sopenharmony_ci> **NOTE**<br> 1035e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1036e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCachedGnssLocationsSize](js-apis-geoLocationManager.md#geolocationmanagergetcachedgnsslocationssize-1). 1037e41f4b71Sopenharmony_ci 1038e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1039e41f4b71Sopenharmony_ci 1040e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 1041e41f4b71Sopenharmony_ci 1042e41f4b71Sopenharmony_ci**Return value** 1043e41f4b71Sopenharmony_ci 1044e41f4b71Sopenharmony_ci | Type| Description| 1045e41f4b71Sopenharmony_ci | -------- | -------- | 1046e41f4b71Sopenharmony_ci | Promise<number> | Promise used to return the result.| 1047e41f4b71Sopenharmony_ci 1048e41f4b71Sopenharmony_ci**Example** 1049e41f4b71Sopenharmony_ci 1050e41f4b71Sopenharmony_ci ```ts 1051e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 1052e41f4b71Sopenharmony_ci geolocation.getCachedGnssLocationsSize().then((result) => { 1053e41f4b71Sopenharmony_ci console.log('promise, getCachedGnssLocationsSize: ' + JSON.stringify(result)); 1054e41f4b71Sopenharmony_ci }); 1055e41f4b71Sopenharmony_ci ``` 1056e41f4b71Sopenharmony_ci 1057e41f4b71Sopenharmony_ci 1058e41f4b71Sopenharmony_ci## geolocation.flushCachedGnssLocations<sup>(deprecated)</sup> 1059e41f4b71Sopenharmony_ci 1060e41f4b71Sopenharmony_ciflushCachedGnssLocations(callback: AsyncCallback<boolean>): void; 1061e41f4b71Sopenharmony_ci 1062e41f4b71Sopenharmony_ciObtains all cached GNSS locations and clears the GNSS cache queue. This API uses an asynchronous callback to return the result. 1063e41f4b71Sopenharmony_ci 1064e41f4b71Sopenharmony_ci> **NOTE**<br> 1065e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1066e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.flushCachedGnssLocations](js-apis-geoLocationManager.md#geolocationmanagerflushcachedgnsslocations). 1067e41f4b71Sopenharmony_ci 1068e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1069e41f4b71Sopenharmony_ci 1070e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 1071e41f4b71Sopenharmony_ci 1072e41f4b71Sopenharmony_ci**Parameters** 1073e41f4b71Sopenharmony_ci 1074e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 1075e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 1076e41f4b71Sopenharmony_ci | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.| 1077e41f4b71Sopenharmony_ci 1078e41f4b71Sopenharmony_ci**Example** 1079e41f4b71Sopenharmony_ci 1080e41f4b71Sopenharmony_ci ```ts 1081e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 1082e41f4b71Sopenharmony_ci geolocation.flushCachedGnssLocations((err, result) => { 1083e41f4b71Sopenharmony_ci if (err) { 1084e41f4b71Sopenharmony_ci console.log('flushCachedGnssLocations: err=' + JSON.stringify(err)); 1085e41f4b71Sopenharmony_ci } 1086e41f4b71Sopenharmony_ci if (result) { 1087e41f4b71Sopenharmony_ci console.log('flushCachedGnssLocations: result=' + JSON.stringify(result)); 1088e41f4b71Sopenharmony_ci } 1089e41f4b71Sopenharmony_ci }); 1090e41f4b71Sopenharmony_ci ``` 1091e41f4b71Sopenharmony_ci 1092e41f4b71Sopenharmony_ci 1093e41f4b71Sopenharmony_ci## geolocation.flushCachedGnssLocations<sup>(deprecated)</sup> 1094e41f4b71Sopenharmony_ci 1095e41f4b71Sopenharmony_ciflushCachedGnssLocations(): Promise<boolean>; 1096e41f4b71Sopenharmony_ci 1097e41f4b71Sopenharmony_ciObtains all cached GNSS locations and clears the GNSS cache queue. This API uses a promise to return the result. 1098e41f4b71Sopenharmony_ci 1099e41f4b71Sopenharmony_ci> **NOTE**<br> 1100e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1101e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.flushCachedGnssLocations](js-apis-geoLocationManager.md#geolocationmanagerflushcachedgnsslocations-1). 1102e41f4b71Sopenharmony_ci 1103e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1104e41f4b71Sopenharmony_ci 1105e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 1106e41f4b71Sopenharmony_ci 1107e41f4b71Sopenharmony_ci**Return value** 1108e41f4b71Sopenharmony_ci 1109e41f4b71Sopenharmony_ci | Type| Description| 1110e41f4b71Sopenharmony_ci | -------- | -------- | 1111e41f4b71Sopenharmony_ci | Promise<boolean>| Promise used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.| 1112e41f4b71Sopenharmony_ci 1113e41f4b71Sopenharmony_ci**Example** 1114e41f4b71Sopenharmony_ci 1115e41f4b71Sopenharmony_ci ```ts 1116e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 1117e41f4b71Sopenharmony_ci geolocation.flushCachedGnssLocations().then((result) => { 1118e41f4b71Sopenharmony_ci console.log('promise, flushCachedGnssLocations: ' + JSON.stringify(result)); 1119e41f4b71Sopenharmony_ci }); 1120e41f4b71Sopenharmony_ci ``` 1121e41f4b71Sopenharmony_ci 1122e41f4b71Sopenharmony_ci 1123e41f4b71Sopenharmony_ci## geolocation.sendCommand<sup>(deprecated)</sup> 1124e41f4b71Sopenharmony_ci 1125e41f4b71Sopenharmony_cisendCommand(command: LocationCommand, callback: AsyncCallback<boolean>): void; 1126e41f4b71Sopenharmony_ci 1127e41f4b71Sopenharmony_ciSends an extended command to the location subsystem. This API uses an asynchronous callback to return the result. 1128e41f4b71Sopenharmony_ci 1129e41f4b71Sopenharmony_ci> **NOTE**<br> 1130e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1131e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.sendCommand](js-apis-geoLocationManager.md#geolocationmanagersendcommand). 1132e41f4b71Sopenharmony_ci 1133e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1134e41f4b71Sopenharmony_ci 1135e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 1136e41f4b71Sopenharmony_ci 1137e41f4b71Sopenharmony_ci**Parameters** 1138e41f4b71Sopenharmony_ci 1139e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 1140e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 1141e41f4b71Sopenharmony_ci | command | [LocationCommand](#locationcommanddeprecated) | Yes| Extended command (string) to be sent.| 1142e41f4b71Sopenharmony_ci | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.| 1143e41f4b71Sopenharmony_ci 1144e41f4b71Sopenharmony_ci**Example** 1145e41f4b71Sopenharmony_ci 1146e41f4b71Sopenharmony_ci ```ts 1147e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 1148e41f4b71Sopenharmony_ci let requestInfo:geolocation.LocationCommand = {'scenario': 0x301, 'command': "command_1"}; 1149e41f4b71Sopenharmony_ci geolocation.sendCommand(requestInfo, (err, result) => { 1150e41f4b71Sopenharmony_ci if (err) { 1151e41f4b71Sopenharmony_ci console.log('sendCommand: err=' + JSON.stringify(err)); 1152e41f4b71Sopenharmony_ci } 1153e41f4b71Sopenharmony_ci if (result) { 1154e41f4b71Sopenharmony_ci console.log('sendCommand: result=' + JSON.stringify(result)); 1155e41f4b71Sopenharmony_ci } 1156e41f4b71Sopenharmony_ci }); 1157e41f4b71Sopenharmony_ci ``` 1158e41f4b71Sopenharmony_ci 1159e41f4b71Sopenharmony_ci 1160e41f4b71Sopenharmony_ci## geolocation.sendCommand<sup>(deprecated)</sup> 1161e41f4b71Sopenharmony_ci 1162e41f4b71Sopenharmony_cisendCommand(command: LocationCommand): Promise<boolean>; 1163e41f4b71Sopenharmony_ci 1164e41f4b71Sopenharmony_ciSends an extended command to the location subsystem. This API uses a promise to return the result. 1165e41f4b71Sopenharmony_ci 1166e41f4b71Sopenharmony_ci> **NOTE**<br> 1167e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1168e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.sendCommand](js-apis-geoLocationManager.md#geolocationmanagersendcommand). 1169e41f4b71Sopenharmony_ci 1170e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1171e41f4b71Sopenharmony_ci 1172e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 1173e41f4b71Sopenharmony_ci 1174e41f4b71Sopenharmony_ci**Parameters** 1175e41f4b71Sopenharmony_ci 1176e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 1177e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 1178e41f4b71Sopenharmony_ci | command | [LocationCommand](#locationcommanddeprecated) | Yes| Extended command (string) to be sent.| 1179e41f4b71Sopenharmony_ci 1180e41f4b71Sopenharmony_ci**Return value** 1181e41f4b71Sopenharmony_ci 1182e41f4b71Sopenharmony_ci | Type| Description| 1183e41f4b71Sopenharmony_ci | -------- | -------- | 1184e41f4b71Sopenharmony_ci | Promise<boolean> | Promise used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.| 1185e41f4b71Sopenharmony_ci 1186e41f4b71Sopenharmony_ci**Example** 1187e41f4b71Sopenharmony_ci 1188e41f4b71Sopenharmony_ci ```ts 1189e41f4b71Sopenharmony_ci import geolocation from '@ohos.geolocation'; 1190e41f4b71Sopenharmony_ci let requestInfo:geolocation.LocationCommand = {'scenario': 0x301, 'command': "command_1"}; 1191e41f4b71Sopenharmony_ci geolocation.sendCommand(requestInfo).then((result) => { 1192e41f4b71Sopenharmony_ci console.log('promise, sendCommand: ' + JSON.stringify(result)); 1193e41f4b71Sopenharmony_ci }); 1194e41f4b71Sopenharmony_ci ``` 1195e41f4b71Sopenharmony_ci 1196e41f4b71Sopenharmony_ci 1197e41f4b71Sopenharmony_ci## ReverseGeoCodeRequest<sup>(deprecated)</sup> 1198e41f4b71Sopenharmony_ci 1199e41f4b71Sopenharmony_ciDefines a reverse geocoding request. 1200e41f4b71Sopenharmony_ci 1201e41f4b71Sopenharmony_ci> **NOTE**<br> 1202e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.ReverseGeoCodeRequest](js-apis-geoLocationManager.md#reversegeocoderequest). 1203e41f4b71Sopenharmony_ci 1204e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1205e41f4b71Sopenharmony_ci 1206e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geocoder 1207e41f4b71Sopenharmony_ci 1208e41f4b71Sopenharmony_ci| Name| Type| Read Only| Optional| Description| 1209e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 1210e41f4b71Sopenharmony_ci| locale | string | No| Yes| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.| 1211e41f4b71Sopenharmony_ci| latitude | number | No| No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude. The value ranges from **-90** to **90**.| 1212e41f4b71Sopenharmony_ci| longitude | number | No| No| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude . The value ranges from **-180** to **180**.| 1213e41f4b71Sopenharmony_ci| maxItems | number | No| Yes| Maximum number of location records to be returned. The value must be greater than or equal to **0**. A value smaller than **10** is recommended.| 1214e41f4b71Sopenharmony_ci 1215e41f4b71Sopenharmony_ci 1216e41f4b71Sopenharmony_ci## GeoCodeRequest<sup>(deprecated)</sup> 1217e41f4b71Sopenharmony_ci 1218e41f4b71Sopenharmony_ciDefines a reverse geocoding request. 1219e41f4b71Sopenharmony_ci 1220e41f4b71Sopenharmony_ci> **NOTE**<br> 1221e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.GeoCodeRequest](js-apis-geoLocationManager.md#geocoderequest). 1222e41f4b71Sopenharmony_ci 1223e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1224e41f4b71Sopenharmony_ci 1225e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geocoder 1226e41f4b71Sopenharmony_ci 1227e41f4b71Sopenharmony_ci| Name| Type| Read Only| Optional| Description| 1228e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 1229e41f4b71Sopenharmony_ci| locale | string | No| Yes| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.| 1230e41f4b71Sopenharmony_ci| description | string | No| No| Location description, for example, **No. xx, xx Road, Pudong New District, Shanghai**.| 1231e41f4b71Sopenharmony_ci| maxItems | number | No| Yes| Maximum number of location records to be returned. The value must be greater than or equal to **0**. A value smaller than **10** is recommended.| 1232e41f4b71Sopenharmony_ci| minLatitude | number | No| Yes| Minimum latitude. This parameter is used with **minLongitude**, **maxLatitude**, and **maxLongitude** to specify the latitude and longitude ranges. The value ranges from **-90** to **90**.| 1233e41f4b71Sopenharmony_ci| minLongitude | number | No| Yes| Minimum longitude. The value ranges from **-180** to **180**.| 1234e41f4b71Sopenharmony_ci| maxLatitude | number | No| Yes| Maximum latitude. The value ranges from **-90** to **90**.| 1235e41f4b71Sopenharmony_ci| maxLongitude | number | No| Yes| Maximum longitude. The value ranges from **-180** to **180**.| 1236e41f4b71Sopenharmony_ci 1237e41f4b71Sopenharmony_ci 1238e41f4b71Sopenharmony_ci## GeoAddress<sup>(deprecated)</sup> 1239e41f4b71Sopenharmony_ci 1240e41f4b71Sopenharmony_ciGeocoding address information. 1241e41f4b71Sopenharmony_ci 1242e41f4b71Sopenharmony_ci> **NOTE**<br> 1243e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.GeoAddress](js-apis-geoLocationManager.md#geoaddress). 1244e41f4b71Sopenharmony_ci 1245e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1246e41f4b71Sopenharmony_ci 1247e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geocoder 1248e41f4b71Sopenharmony_ci 1249e41f4b71Sopenharmony_ci| Name| Type| Read Only| Optional| Description| 1250e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 1251e41f4b71Sopenharmony_ci| latitude<sup>7+</sup> | number | No| Yes| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude. The value ranges from **-90** to **90**.| 1252e41f4b71Sopenharmony_ci| longitude<sup>7+</sup> | number | No| Yes| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude . The value ranges from **-180** to **180**.| 1253e41f4b71Sopenharmony_ci| locale<sup>7+</sup> | string | No| Yes| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.| 1254e41f4b71Sopenharmony_ci| placeName<sup>7+</sup> | string | No| Yes| Landmark of the location.| 1255e41f4b71Sopenharmony_ci| countryCode<sup>7+</sup> | string | No| Yes| Country code.| 1256e41f4b71Sopenharmony_ci| countryName<sup>7+</sup> | string | No| Yes| Country name.| 1257e41f4b71Sopenharmony_ci| administrativeArea<sup>7+</sup> | string | No| Yes| Administrative region name.| 1258e41f4b71Sopenharmony_ci| subAdministrativeArea<sup>7+</sup> | string | No| Yes| Sub-administrative region name.| 1259e41f4b71Sopenharmony_ci| locality<sup>7+</sup> | string | No| Yes| Locality information.| 1260e41f4b71Sopenharmony_ci| subLocality<sup>7+</sup> | string | No| Yes| Sub-locality information.| 1261e41f4b71Sopenharmony_ci| roadName<sup>7+</sup> | string | No| Yes| Road name.| 1262e41f4b71Sopenharmony_ci| subRoadName<sup>7+</sup> | string | No| Yes| Auxiliary road information.| 1263e41f4b71Sopenharmony_ci| premises<sup>7+</sup> | string | No| Yes| House information.| 1264e41f4b71Sopenharmony_ci| postalCode<sup>7+</sup> | string | No| Yes| Postal code.| 1265e41f4b71Sopenharmony_ci| phoneNumber<sup>7+</sup> | string | No| Yes| Phone number.| 1266e41f4b71Sopenharmony_ci| addressUrl<sup>7+</sup> | string | No| Yes| Website URL.| 1267e41f4b71Sopenharmony_ci| descriptions<sup>7+</sup> | Array<string> | No| Yes| Additional descriptions.| 1268e41f4b71Sopenharmony_ci| descriptionsSize<sup>7+</sup> | number | No| Yes| Total number of additional descriptions. The value must be greater than or equal to **0**. A value smaller than **10** is recommended.| 1269e41f4b71Sopenharmony_ci 1270e41f4b71Sopenharmony_ci 1271e41f4b71Sopenharmony_ci## LocationRequest<sup>(deprecated)</sup> 1272e41f4b71Sopenharmony_ci 1273e41f4b71Sopenharmony_ciDefines a location request. 1274e41f4b71Sopenharmony_ci 1275e41f4b71Sopenharmony_ci> **NOTE**<br> 1276e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationRequest](js-apis-geoLocationManager.md#locationrequest). 1277e41f4b71Sopenharmony_ci 1278e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1279e41f4b71Sopenharmony_ci 1280e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 1281e41f4b71Sopenharmony_ci 1282e41f4b71Sopenharmony_ci| Name| Type| Read Only| Optional| Description| 1283e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 1284e41f4b71Sopenharmony_ci| priority | [LocationRequestPriority](#locationrequestprioritydeprecated) | No| Yes| Priority of the location request. For details about the value range, see [LocationRequestPriority](#locationrequestprioritydeprecated).| 1285e41f4b71Sopenharmony_ci| scenario | [LocationRequestScenario](#locationrequestscenariodeprecated) | No| Yes| Scenario of the location request. For details about the value range, see [LocationRequestScenario](#locationrequestscenariodeprecated).| 1286e41f4b71Sopenharmony_ci| timeInterval | number | No| Yes| Time interval at which location information is reported, in seconds. The value must be greater than **0**.| 1287e41f4b71Sopenharmony_ci| distanceInterval | number | No| Yes| Distance interval at which location information is reported. The value must be greater than **0**, in meters.| 1288e41f4b71Sopenharmony_ci| maxAccuracy | number | No| Yes| Location accuracy, in meters.<br>This parameter is valid only when the precise location function is enabled (both the **ohos.permission.APPROXIMATELY\_LOCATION** and **ohos.permission.LOCATION** permissions are granted), and is invalid when the approximate location function is enabled (only the **ohos.permission.APPROXIMATELY\_LOCATION** permission is enabled).<br>The specified value must be greater than or equal to **0**. The default value is **0**.<br>If **scenario** is set to **NAVIGATION**, **TRAJECTORY\_TRACKING**, or **CAR\_HAILING** or **priority** is set to **ACCURACY**, you are advised to set **maxAccuracy** to a value greater than **10**.<br>If scenario is set to **DAILY\_LIFE_SERVICE** or **NO\_POWER** or **priority** is set to **LOW\_POWER** or **FIRST\_FIX**, you are advised to set **maxAccuracy** to a value greater than **100**.| 1289e41f4b71Sopenharmony_ci 1290e41f4b71Sopenharmony_ci 1291e41f4b71Sopenharmony_ci## CurrentLocationRequest<sup>(deprecated)</sup> 1292e41f4b71Sopenharmony_ci 1293e41f4b71Sopenharmony_ciDefines a location request. 1294e41f4b71Sopenharmony_ci 1295e41f4b71Sopenharmony_ci> **NOTE**<br> 1296e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CurrentLocationRequest](js-apis-geoLocationManager.md#currentlocationrequest). 1297e41f4b71Sopenharmony_ci 1298e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1299e41f4b71Sopenharmony_ci 1300e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 1301e41f4b71Sopenharmony_ci 1302e41f4b71Sopenharmony_ci| Name| Type| Read Only| Optional| Description| 1303e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 1304e41f4b71Sopenharmony_ci| priority | [LocationRequestPriority](#locationrequestprioritydeprecated) | No| Yes| Priority of the location request. For details about the value range, see [LocationRequestPriority](#locationrequestprioritydeprecated).| 1305e41f4b71Sopenharmony_ci| scenario | [LocationRequestScenario](#locationrequestscenariodeprecated) | No| Yes| Scenario of the location request. For details about the value range, see [LocationRequestScenario](#locationrequestscenariodeprecated).| 1306e41f4b71Sopenharmony_ci| maxAccuracy | number | No| Yes| Location accuracy, in meters.<br>This parameter is valid only when the precise location function is enabled (both the **ohos.permission.APPROXIMATELY\_LOCATION** and **ohos.permission.LOCATION** permissions are granted), and is invalid when the approximate location function is enabled (only the **ohos.permission.APPROXIMATELY\_LOCATION** permission is enabled).<br>The specified value must be greater than or equal to **0**. The default value is **0**.<br>If **scenario** is set to **NAVIGATION**, **TRAJECTORY\_TRACKING**, or **CAR\_HAILING** or **priority** is set to **ACCURACY**, you are advised to set **maxAccuracy** to a value greater than **10**.<br>If scenario is set to **DAILY\_LIFE_SERVICE** or **NO\_POWER** or **priority** is set to **LOW\_POWER** or **FIRST\_FIX**, you are advised to set **maxAccuracy** to a value greater than **100**.| 1307e41f4b71Sopenharmony_ci| timeoutMs | number | No| Yes| Timeout duration, in milliseconds. The minimum value is **1000**. The value must be greater than or equal to **1000**.| 1308e41f4b71Sopenharmony_ci 1309e41f4b71Sopenharmony_ci 1310e41f4b71Sopenharmony_ci## SatelliteStatusInfo<sup>(deprecated)</sup> 1311e41f4b71Sopenharmony_ci 1312e41f4b71Sopenharmony_ciDefines the satellite status information. 1313e41f4b71Sopenharmony_ci 1314e41f4b71Sopenharmony_ci> **NOTE**<br> 1315e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1316e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.SatelliteStatusInfo](js-apis-geoLocationManager.md#satellitestatusinfo). 1317e41f4b71Sopenharmony_ci 1318e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1319e41f4b71Sopenharmony_ci 1320e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 1321e41f4b71Sopenharmony_ci 1322e41f4b71Sopenharmony_ci| Name| Type| Read Only| Optional| Description| 1323e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 1324e41f4b71Sopenharmony_ci| satellitesNumber | number | No| No| Number of satellites. The value must be greater than or equal to **0**.| 1325e41f4b71Sopenharmony_ci| satelliteIds | Array<number> | No| No| Array of satellite IDs. The value must be greater than or equal to **0**.| 1326e41f4b71Sopenharmony_ci| carrierToNoiseDensitys | Array<number> | No| No| Carrier-to-noise density ratio, that is, **cn0**. The value must be greater than **0**.| 1327e41f4b71Sopenharmony_ci| altitudes | Array<number> | No| No| Satellite altitude angle information. The value ranges from **-90** to **90**, in degrees.| 1328e41f4b71Sopenharmony_ci| azimuths | Array<number> | No| No| Azimuth information. The value ranges from **0** to **360**, in degrees.| 1329e41f4b71Sopenharmony_ci| carrierFrequencies | Array<number> | No| No| Carrier frequency. The value must be greater than or equal to **0**, in Hz.| 1330e41f4b71Sopenharmony_ci 1331e41f4b71Sopenharmony_ci 1332e41f4b71Sopenharmony_ci## CachedGnssLocationsRequest<sup>(deprecated)</sup> 1333e41f4b71Sopenharmony_ci 1334e41f4b71Sopenharmony_ciRepresents a request for reporting cached GNSS locations. 1335e41f4b71Sopenharmony_ci 1336e41f4b71Sopenharmony_ci> **NOTE**<br> 1337e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1338e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CachedGnssLocationsRequest](js-apis-geoLocationManager.md#cachedgnsslocationsrequest). 1339e41f4b71Sopenharmony_ci 1340e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1341e41f4b71Sopenharmony_ci 1342e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Gnss 1343e41f4b71Sopenharmony_ci 1344e41f4b71Sopenharmony_ci| Name| Type| Read Only| Optional| Description| 1345e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 1346e41f4b71Sopenharmony_ci| reportingPeriodSec | number | No| No| Interval for reporting the cached GNSS locations, in milliseconds. The value must be greater than **0**.| 1347e41f4b71Sopenharmony_ci| wakeUpCacheQueueFull | boolean | No| No| **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.| 1348e41f4b71Sopenharmony_ci 1349e41f4b71Sopenharmony_ci 1350e41f4b71Sopenharmony_ci## Geofence<sup>(deprecated)</sup> 1351e41f4b71Sopenharmony_ci 1352e41f4b71Sopenharmony_ciDefines a GNSS geofence. Currently, only circular geofences are supported. 1353e41f4b71Sopenharmony_ci 1354e41f4b71Sopenharmony_ci> **NOTE**<br> 1355e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1356e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.Geofence](js-apis-geoLocationManager.md#geofence). 1357e41f4b71Sopenharmony_ci 1358e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1359e41f4b71Sopenharmony_ci 1360e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geofence 1361e41f4b71Sopenharmony_ci 1362e41f4b71Sopenharmony_ci| Name| Type| Read Only| Optional| Description| 1363e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 1364e41f4b71Sopenharmony_ci| latitude | number | No| No|Latitude information. The value ranges from **-90** to **90**.| 1365e41f4b71Sopenharmony_ci| longitude | number | No| No| Longitude information. The value ranges from **-180** to **180**.| 1366e41f4b71Sopenharmony_ci| radius | number | No| No| Radius of a circular geofence. The value must be greater than **0**, in meters.| 1367e41f4b71Sopenharmony_ci| expiration | number | No| No| Expiration period of a geofence, in milliseconds. The value must be greater than **0**.| 1368e41f4b71Sopenharmony_ci 1369e41f4b71Sopenharmony_ci 1370e41f4b71Sopenharmony_ci## GeofenceRequest<sup>(deprecated)</sup> 1371e41f4b71Sopenharmony_ci 1372e41f4b71Sopenharmony_ciDefines a geofence request. 1373e41f4b71Sopenharmony_ci 1374e41f4b71Sopenharmony_ci> **NOTE**<br> 1375e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1376e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.GeofenceRequest](js-apis-geoLocationManager.md#geofencerequest). 1377e41f4b71Sopenharmony_ci 1378e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1379e41f4b71Sopenharmony_ci 1380e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Geofence 1381e41f4b71Sopenharmony_ci 1382e41f4b71Sopenharmony_ci| Name| Type| Read Only| Optional| Description| 1383e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 1384e41f4b71Sopenharmony_ci| priority | [LocationRequestPriority](#locationrequestprioritydeprecated) | No| No| Priority of the location information.| 1385e41f4b71Sopenharmony_ci| scenario | [LocationRequestScenario](#locationrequestscenariodeprecated) | No| No| Location scenario.| 1386e41f4b71Sopenharmony_ci| geofence | [Geofence](#geofencedeprecated)| No| No| Geofence information.| 1387e41f4b71Sopenharmony_ci 1388e41f4b71Sopenharmony_ci 1389e41f4b71Sopenharmony_ci## LocationCommand<sup>(deprecated)</sup> 1390e41f4b71Sopenharmony_ci 1391e41f4b71Sopenharmony_ciDefines a location command. 1392e41f4b71Sopenharmony_ci 1393e41f4b71Sopenharmony_ci> **NOTE**<br> 1394e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1395e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationCommand](js-apis-geoLocationManager.md#locationcommand). 1396e41f4b71Sopenharmony_ci 1397e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1398e41f4b71Sopenharmony_ci 1399e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 1400e41f4b71Sopenharmony_ci 1401e41f4b71Sopenharmony_ci| Name| Type| Read Only| Optional| Description| 1402e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 1403e41f4b71Sopenharmony_ci| scenario | [LocationRequestScenario](#locationrequestscenariodeprecated) | No| No| Location scenario.| 1404e41f4b71Sopenharmony_ci| command | string | No| No| Extended command, in the string format.| 1405e41f4b71Sopenharmony_ci 1406e41f4b71Sopenharmony_ci 1407e41f4b71Sopenharmony_ci## Location<sup>(deprecated)</sup> 1408e41f4b71Sopenharmony_ci 1409e41f4b71Sopenharmony_ciDefines location information. 1410e41f4b71Sopenharmony_ci 1411e41f4b71Sopenharmony_ci> **NOTE**<br> 1412e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.Location](js-apis-geoLocationManager.md#location). 1413e41f4b71Sopenharmony_ci 1414e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1415e41f4b71Sopenharmony_ci 1416e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 1417e41f4b71Sopenharmony_ci 1418e41f4b71Sopenharmony_ci| Name| Type| Read Only| Optional| Description| 1419e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 1420e41f4b71Sopenharmony_ci| latitude<sup>7+</sup> | number | No| No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude. The value ranges from **-90** to **90**.| 1421e41f4b71Sopenharmony_ci| longitude<sup>7+</sup> | number | No| No| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude . The value ranges from **-180** to **180**.| 1422e41f4b71Sopenharmony_ci| altitude<sup>7+</sup> | number | No| No| Location altitude, in meters.| 1423e41f4b71Sopenharmony_ci| accuracy<sup>7+</sup> | number | No| No| Location accuracy, in meters.| 1424e41f4b71Sopenharmony_ci| speed<sup>7+</sup> | number | No| No| Speed, in m/s.| 1425e41f4b71Sopenharmony_ci| timeStamp<sup>7+</sup> | number | No| No| Location timestamp in the UTC format.| 1426e41f4b71Sopenharmony_ci| direction<sup>7+</sup> | number | No| No| Direction information. The value ranges from **0** to **360**, in degrees.| 1427e41f4b71Sopenharmony_ci| timeSinceBoot<sup>7+</sup> | number | No| No| Location timestamp since boot.| 1428e41f4b71Sopenharmony_ci| additions<sup>7+</sup> | Array<string> | No| Yes| Additional description.| 1429e41f4b71Sopenharmony_ci| additionSize<sup>7+</sup> | number | No| Yes| Number of additional descriptions. The value must be greater than or equal to **0**.| 1430e41f4b71Sopenharmony_ci 1431e41f4b71Sopenharmony_ci 1432e41f4b71Sopenharmony_ci## LocationPrivacyType<sup>(deprecated)</sup> 1433e41f4b71Sopenharmony_ci 1434e41f4b71Sopenharmony_ciDefines the privacy statement type. 1435e41f4b71Sopenharmony_ci 1436e41f4b71Sopenharmony_ci> **NOTE**<br> 1437e41f4b71Sopenharmony_ci> This API is supported since API version 8. 1438e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use **geoLocationManager.LocationPrivacyType**, which is available only for system applications. 1439e41f4b71Sopenharmony_ci 1440e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1441e41f4b71Sopenharmony_ci 1442e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 1443e41f4b71Sopenharmony_ci 1444e41f4b71Sopenharmony_ci| Name| Value| Description| 1445e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 1446e41f4b71Sopenharmony_ci| OTHERS | 0 | Other scenarios. Reserved field.| 1447e41f4b71Sopenharmony_ci| STARTUP | 1 | Privacy statement displayed in the startup wizard. | 1448e41f4b71Sopenharmony_ci| CORE_LOCATION | 2 | Privacy statement displayed when enabling the location service.| 1449e41f4b71Sopenharmony_ci 1450e41f4b71Sopenharmony_ci 1451e41f4b71Sopenharmony_ci## LocationRequestPriority<sup>(deprecated)</sup> 1452e41f4b71Sopenharmony_ci 1453e41f4b71Sopenharmony_ciSets the priority of a location request. 1454e41f4b71Sopenharmony_ci 1455e41f4b71Sopenharmony_ci> **NOTE**<br> 1456e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationRequestPriority](js-apis-geoLocationManager.md#locationrequestpriority). 1457e41f4b71Sopenharmony_ci 1458e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1459e41f4b71Sopenharmony_ci 1460e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 1461e41f4b71Sopenharmony_ci 1462e41f4b71Sopenharmony_ci| Name| Value| Description| 1463e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 1464e41f4b71Sopenharmony_ci| UNSET | 0x200 | Priority unspecified.<br>If this option is used, [LocationRequestPriority](#locationrequestprioritydeprecated) is invalid.| 1465e41f4b71Sopenharmony_ci| ACCURACY | 0x201 | Location accuracy preferred.<br>This policy mainly uses the GNSS positioning technology. In an open area, the technology can achieve the meter-level location accuracy, depending on the hardware performance of the device. However, in a shielded environment, the location accuracy may significantly decrease.| 1466e41f4b71Sopenharmony_ci| LOW_POWER | 0x202 | Power efficiency preferred.<br>This policy mainly uses the base station positioning, WLAN positioning, and Bluetooth positioning technologies to obtain device location in both indoor and outdoor scenarios. The location accuracy depends on the distribution of surrounding base stations, visible WLANs, and Bluetooth devices and therefore may fluctuate greatly. This policy is recommended and can reduce power consumption when your application does not require high location accuracy or when base stations, visible WLANs, and Bluetooth devices are densely distributed.| 1467e41f4b71Sopenharmony_ci| FIRST_FIX | 0x203 | Fast location preferred. Use this option if you want to obtain a location as fast as possible.<br>This policy uses the GNSS positioning, base station positioning, WLAN positioning, and Bluetooth positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios. When all positioning technologies provide a location result, the system provides the most accurate location result for your application. It can lead to significant hardware resource consumption and power consumption.| 1468e41f4b71Sopenharmony_ci 1469e41f4b71Sopenharmony_ci 1470e41f4b71Sopenharmony_ci## LocationRequestScenario<sup>(deprecated)</sup> 1471e41f4b71Sopenharmony_ci 1472e41f4b71Sopenharmony_ci Defines the location scenario in a location request. 1473e41f4b71Sopenharmony_ci 1474e41f4b71Sopenharmony_ci> **NOTE**<br> 1475e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationRequestScenario](js-apis-geoLocationManager.md#locationrequestscenario). 1476e41f4b71Sopenharmony_ci 1477e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1478e41f4b71Sopenharmony_ci 1479e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 1480e41f4b71Sopenharmony_ci 1481e41f4b71Sopenharmony_ci| Name| Value| Description| 1482e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 1483e41f4b71Sopenharmony_ci| UNSET | 0x300 | Scenario unspecified.<br>If this option is used, [LocationRequestScenario](#locationrequestscenariodeprecated) is invalid.| 1484e41f4b71Sopenharmony_ci| NAVIGATION | 0x301 | Navigation scenario.<br>This option is applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking.<br>In this scenario, GNSS positioning is used to provide location services to ensure the optimal location accuracy of the system.<br>The location result is reported at a minimum interval of 1 second by default.| 1485e41f4b71Sopenharmony_ci| TRAJECTORY_TRACKING | 0x302 | Trajectory tracking scenario.<br>This option is applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.<br>The location result is reported at a minimum interval of 1 second by default.| 1486e41f4b71Sopenharmony_ci| CAR_HAILING | 0x303 | Ride hailing scenario.<br>This option is applicable when your application needs to obtain the current location of a user who is hailing a taxi.<br>The location result is reported at a minimum interval of 1 second by default.| 1487e41f4b71Sopenharmony_ci| DAILY_LIFE_SERVICE | 0x304 | Daily life service scenario.<br>This option is applicable when your application only needs the approximate user location for recommendations and push notifications in scenarios such as when the user is browsing news, shopping online, and ordering food.<br>The location result is reported at a minimum interval of 1 second by default.| 1488e41f4b71Sopenharmony_ci| NO_POWER | 0x305 | Power efficiency scenario.<br>This option is applicable when 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.| 1489e41f4b71Sopenharmony_ci 1490e41f4b71Sopenharmony_ci 1491e41f4b71Sopenharmony_ci## GeoLocationErrorCode<sup>(deprecated)</sup> 1492e41f4b71Sopenharmony_ci 1493e41f4b71Sopenharmony_ciEnumerates error codes of the location service. 1494e41f4b71Sopenharmony_ci 1495e41f4b71Sopenharmony_ci> **NOTE**<br> 1496e41f4b71Sopenharmony_ci> This API is deprecated since API version 9. You are advised to use [geoLocationManager](errorcode-geoLocationManager.md). 1497e41f4b71Sopenharmony_ci 1498e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.LOCATION 1499e41f4b71Sopenharmony_ci 1500e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Location.Location.Core 1501e41f4b71Sopenharmony_ci 1502e41f4b71Sopenharmony_ci| Name| Value| Description| 1503e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 1504e41f4b71Sopenharmony_ci| INPUT_PARAMS_ERROR<sup>7+</sup> | 101 | Incorrect input parameters.| 1505e41f4b71Sopenharmony_ci| REVERSE_GEOCODE_ERROR<sup>7+</sup> | 102 | Failed to call the reverse geocoding API.| 1506e41f4b71Sopenharmony_ci| GEOCODE_ERROR<sup>7+</sup> | 103 | Failed to call the geocoding API.| 1507e41f4b71Sopenharmony_ci| LOCATOR_ERROR<sup>7+</sup> | 104 | Failed to obtain the location.| 1508e41f4b71Sopenharmony_ci| LOCATION_SWITCH_ERROR<sup>7+</sup> | 105 | Failed to change the location service switch.| 1509e41f4b71Sopenharmony_ci| LAST_KNOWN_LOCATION_ERROR<sup>7+</sup> | 106 | Failed to obtain the previous location.| 1510e41f4b71Sopenharmony_ci| LOCATION_REQUEST_TIMEOUT_ERROR<sup>7+</sup> | 107 | Failed to obtain the location within the specified time.| 1511