js-apis-geolocation.md 56.7 KB
Newer Older
S
shawn_he 已提交
1
# Geolocation
Z
zengyawen 已提交
2

S
shawn_he 已提交
3
The Geolocation module provides location services such as GNSS positioning, network positioning, geocoding, reverse geocoding, country code and geofencing.
Z
zengyawen 已提交
4

S
shawn_he 已提交
5
> **NOTE**
Z
zengyawen 已提交
6
> 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.
S
shawn_he 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [geoLocationManager](js-apis-geoLocationManager.md) instead.

## Applying for Permissions

Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user as described below.

The system provides the following location permissions:
- ohos.permission.LOCATION

- ohos.permission.APPROXIMATELY_LOCATION

- ohos.permission.LOCATION_IN_BACKGROUND

If your application needs to access the device location information, it must first apply for required permissions. Specifically speaking:

S
shawn_he 已提交
22
- API versions earlier than 9: Apply for **ohos.permission.LOCATION**.
S
shawn_he 已提交
23

S
shawn_he 已提交
24
- API version 9 and later: Apply for **ohos.permission.APPROXIMATELY\_LOCATION**, or apply for **ohos.permission.APPROXIMATELY\_LOCATION** and **ohos.permission.LOCATION**. Note that **ohos.permission.LOCATION** cannot be applied for separately.
S
shawn_he 已提交
25 26 27 28 29 30 31 32

| API Version| Location Permission| Permission Application Result| Location Accuracy|
| -------- | -------- | -------- | -------- |
| Earlier than 9| ohos.permission.LOCATION | Success| Location accurate to meters|
| 9 and later| ohos.permission.LOCATION | Failure| No location obtained|
| 9 and later| ohos.permission.APPROXIMATELY_LOCATION | Success| Location accurate to 5 kilometers|
| 9 and later| ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION| Success| Location accurate to meters|

S
shawn_he 已提交
33
If your application needs to access the device location information when running in the background, it must be configured to be able to run in the background and be granted the **ohos.permission.LOCATION\_IN\_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background.
S
shawn_he 已提交
34 35

You can declare the required permission in your application's configuration file. For details, see [Access Control (Permission) Development](../../security/accesstoken-guidelines.md).
Z
zengyawen 已提交
36 37 38 39


## Modules to Import

S
shawn_he 已提交
40
```ts
Z
zengyawen 已提交
41 42 43
import geolocation from '@ohos.geolocation';
```

S
shawn_he 已提交
44
## geolocation.on('locationChange')<sup>(deprecated) </sup>
Z
zengyawen 已提交
45

L
liu-binjun 已提交
46
on(type: 'locationChange', request: LocationRequest, callback: Callback&lt;Location&gt;): void
Z
zengyawen 已提交
47

S
shawn_he 已提交
48 49 50 51
Registers a listener for location changes with a location request initiated. The location result is reported through [LocationRequest](#locationrequest).

> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationchange).
Z
zengyawen 已提交
52

S
shawn_he 已提交
53
**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
54 55 56

**System capability**: SystemCapability.Location.Location.Core

L
liu-binjun 已提交
57 58
**Parameters**

59
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
60
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
61
  | type | string | Yes| Event type. The value **locationChange** indicates a location change event.|
S
shawn_he 已提交
62
  | request |  [LocationRequest](#locationrequest) | Yes| Location request.|
S
shawn_he 已提交
63 64
  | callback | Callback&lt;[Location](#location)&gt; | Yes| Callback used to return the location change event.|

Z
zengyawen 已提交
65

S
shawn_he 已提交
66

L
liu-binjun 已提交
67
**Example**
S
shawn_he 已提交
68 69

  ```ts
L
liu-binjun 已提交
70
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
71 72 73 74 75 76 77 78
  var requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
  var locationChange = (location) => {
      console.log('locationChanger: data: ' + JSON.stringify(location));
  };
  geolocation.on('locationChange', requestInfo, locationChange);
  ```


S
shawn_he 已提交
79
## geolocation.off('locationChange')<sup>(deprecated) </sup>
Z
zengyawen 已提交
80

L
liu-binjun 已提交
81
off(type: 'locationChange', callback?: Callback&lt;Location&gt;): void
Z
zengyawen 已提交
82 83 84

Unregisters the listener for location changes with the corresponding location request deleted.

S
shawn_he 已提交
85 86 87 88
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationchange).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
89 90 91

**System capability**: SystemCapability.Location.Location.Core

L
liu-binjun 已提交
92 93
**Parameters**

94
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
95
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
96
  | type | string | Yes| Event type. The value **locationChange** indicates a location change event.|
S
shawn_he 已提交
97
  | callback | Callback&lt;[Location](#location)&gt; | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
S
shawn_he 已提交
98

Z
zengyawen 已提交
99

L
liu-binjun 已提交
100
**Example**
S
shawn_he 已提交
101 102

  ```ts
L
liu-binjun 已提交
103
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
104 105 106 107 108 109 110 111 112
  var requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
  var locationChange = (location) => {
      console.log('locationChanger: data: ' + JSON.stringify(location));
  };
  geolocation.on('locationChange', requestInfo, locationChange);
  geolocation.off('locationChange', locationChange);
  ```


S
shawn_he 已提交
113
## geolocation.on('locationServiceState')<sup>(deprecated) </sup>
Z
zengyawen 已提交
114

L
liu-binjun 已提交
115
on(type: 'locationServiceState', callback: Callback&lt;boolean&gt;): void
Z
zengyawen 已提交
116 117 118

Registers a listener for location service status change events.

S
shawn_he 已提交
119 120 121 122
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationEnabledChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationenabledchange).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
123 124 125

**System capability**: SystemCapability.Location.Location.Core

L
liu-binjun 已提交
126 127
**Parameters**

128
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
129
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
130 131 132
  | type | string | Yes| Event type. The value **locationServiceState** indicates a location service status change event.|
  | callback | Callback&lt;boolean&gt; | Yes| Callback used to return the location service status change event.|

Z
zengyawen 已提交
133

L
liu-binjun 已提交
134
**Example**
S
shawn_he 已提交
135 136

  ```ts
L
liu-binjun 已提交
137
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
138
  var locationServiceState = (state) => {
L
liu-binjun 已提交
139
      console.log('locationServiceState: ' + JSON.stringify(state));
Z
zengyawen 已提交
140 141 142 143 144
  }
  geolocation.on('locationServiceState', locationServiceState);
  ```


S
shawn_he 已提交
145
## geolocation.off('locationServiceState')<sup>(deprecated) </sup>
Z
zengyawen 已提交
146

L
liu-binjun 已提交
147
off(type: 'locationServiceState', callback?: Callback&lt;boolean&gt;): void;
Z
zengyawen 已提交
148 149 150

Unregisters the listener for location service status change events.

S
shawn_he 已提交
151 152 153 154
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationEnabledChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationenabledchange).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
155 156 157

**System capability**: SystemCapability.Location.Location.Core

L
liu-binjun 已提交
158 159
**Parameters**

160
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
161
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
162
  | type | string | Yes| Event type. The value **locationServiceState** indicates a location service status change event.|
S
shawn_he 已提交
163
  | callback | Callback&lt;boolean&gt; | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
S
shawn_he 已提交
164

Z
zengyawen 已提交
165

L
liu-binjun 已提交
166
**Example**
S
shawn_he 已提交
167 168

  ```ts
L
liu-binjun 已提交
169
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
170
  var locationServiceState = (state) => {
L
liu-binjun 已提交
171
      console.log('locationServiceState: state: ' + JSON.stringify(state));
Z
zengyawen 已提交
172 173 174 175 176 177
  }
  geolocation.on('locationServiceState', locationServiceState);
  geolocation.off('locationServiceState', locationServiceState);
  ```


S
shawn_he 已提交
178
## geolocation.on('cachedGnssLocationsReporting')<sup>(deprecated) </sup>
Z
zengyawen 已提交
179

L
liu-binjun 已提交
180
on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback&lt;Array&lt;Location&gt;&gt;): void;
Z
zengyawen 已提交
181 182 183

Registers a listener for cached GNSS location reports.

S
shawn_he 已提交
184 185 186 187 188
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('cachedGnssLocationsChange')](js-apis-geoLocationManager.md#geolocationmanageroncachedgnsslocationschange).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
189 190 191

**System capability**: SystemCapability.Location.Location.Gnss

L
liu-binjun 已提交
192 193
**Parameters**

194
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
195
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
196
  | type | string | Yes| Event type. The value **cachedGnssLocationsReporting** indicates reporting of cached GNSS locations.|
S
shawn_he 已提交
197 198
  | request |  [CachedGnssLocationsRequest](#cachedgnsslocationsrequest) | Yes| Request for reporting cached GNSS location.|
  | callback | Callback&lt;Array&lt;[Location](#location)&gt;&gt; | Yes| Callback used to return cached GNSS locations.|
S
shawn_he 已提交
199

Z
zengyawen 已提交
200

L
liu-binjun 已提交
201
**Example**
S
shawn_he 已提交
202 203

  ```ts
L
liu-binjun 已提交
204
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
205
  var cachedLocationsCb = (locations) => {
L
liu-binjun 已提交
206
      console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
Z
zengyawen 已提交
207 208 209 210 211 212
  }
  var requestInfo = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true};
  geolocation.on('cachedGnssLocationsReporting', requestInfo, cachedLocationsCb);
  ```


S
shawn_he 已提交
213
## geolocation.off('cachedGnssLocationsReporting')<sup>(deprecated) </sup>
Z
zengyawen 已提交
214

L
liu-binjun 已提交
215
off(type: 'cachedGnssLocationsReporting', callback?: Callback&lt;Array&lt;Location&gt;&gt;): void;
Z
zengyawen 已提交
216 217 218

Unregisters the listener for cached GNSS location reports.

S
shawn_he 已提交
219 220 221 222 223
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('cachedGnssLocationsChange')](js-apis-geoLocationManager.md#geolocationmanageroffcachedgnsslocationschange).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
224 225 226

**System capability**: SystemCapability.Location.Location.Gnss

L
liu-binjun 已提交
227 228
**Parameters**

229
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
230
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
231
  | type | string | Yes| Event type. The value **cachedGnssLocationsReporting** indicates reporting of cached GNSS locations.|
S
shawn_he 已提交
232
  | callback | Callback&lt;Array&lt;[Location](#location)&gt;&gt; | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
S
shawn_he 已提交
233

Z
zengyawen 已提交
234

L
liu-binjun 已提交
235
**Example**
S
shawn_he 已提交
236 237

  ```ts
L
liu-binjun 已提交
238
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
239
  var cachedLocationsCb = (locations) => {
L
liu-binjun 已提交
240
      console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
Z
zengyawen 已提交
241 242 243 244 245 246 247
  }
  var requestInfo = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true};
  geolocation.on('cachedGnssLocationsReporting', requestInfo, cachedLocationsCb);
  geolocation.off('cachedGnssLocationsReporting');
  ```


S
shawn_he 已提交
248
## geolocation.on('gnssStatusChange')<sup>(deprecated) </sup>
Z
zengyawen 已提交
249

L
liu-binjun 已提交
250
on(type: 'gnssStatusChange', callback: Callback&lt;SatelliteStatusInfo&gt;): void;
Z
zengyawen 已提交
251 252 253

Registers a listener for GNSS satellite status change events.

S
shawn_he 已提交
254 255 256 257 258
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('satelliteStatusChange')](js-apis-geoLocationManager.md#geolocationmanageronsatellitestatuschange).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
259 260 261

**System capability**: SystemCapability.Location.Location.Gnss

L
liu-binjun 已提交
262 263
**Parameters**

264
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
265
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
266
  | type | string | Yes| Event type. The value **gnssStatusChange** indicates a GNSS satellite status change.|
S
shawn_he 已提交
267
  | callback | Callback&lt;[SatelliteStatusInfo](#satellitestatusinfo)&gt; | Yes| Callback used to return GNSS satellite status changes.|
S
shawn_he 已提交
268

Z
zengyawen 已提交
269

L
liu-binjun 已提交
270
**Example**
S
shawn_he 已提交
271 272

  ```ts
L
liu-binjun 已提交
273
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
274
  var gnssStatusCb = (satelliteStatusInfo) => {
L
liu-binjun 已提交
275
      console.log('gnssStatusChange: ' + JSON.stringify(satelliteStatusInfo));
Z
zengyawen 已提交
276 277 278 279 280
  }
  geolocation.on('gnssStatusChange', gnssStatusCb);
  ```


S
shawn_he 已提交
281
## geolocation.off('gnssStatusChange')<sup>(deprecated) </sup>
Z
zengyawen 已提交
282

L
liu-binjun 已提交
283
off(type: 'gnssStatusChange', callback?: Callback&lt;SatelliteStatusInfo&gt;): void;
Z
zengyawen 已提交
284 285 286

Unregisters the listener for GNSS satellite status change events.

S
shawn_he 已提交
287 288 289 290 291
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('satelliteStatusChange')](js-apis-geoLocationManager.md#geolocationmanageroffsatellitestatuschange).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
292 293 294

**System capability**: SystemCapability.Location.Location.Gnss

L
liu-binjun 已提交
295 296
**Parameters**

297
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
298
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
299
  | type | string | Yes| Event type. The value **gnssStatusChange** indicates a GNSS satellite status change.|
S
shawn_he 已提交
300
  | callback | Callback&lt;[SatelliteStatusInfo](#satellitestatusinfo)&gt; | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
Z
zengyawen 已提交
301

L
liu-binjun 已提交
302
**Example**
S
shawn_he 已提交
303 304

  ```ts
L
liu-binjun 已提交
305
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
306
  var gnssStatusCb = (satelliteStatusInfo) => {
L
liu-binjun 已提交
307
      console.log('gnssStatusChange: ' + JSON.stringify(satelliteStatusInfo));
Z
zengyawen 已提交
308 309 310 311 312 313
  }
  geolocation.on('gnssStatusChange', gnssStatusCb);
  geolocation.off('gnssStatusChange', gnssStatusCb);
  ```


S
shawn_he 已提交
314
## geolocation.on('nmeaMessageChange')<sup>(deprecated) </sup>
Z
zengyawen 已提交
315

L
liu-binjun 已提交
316
on(type: 'nmeaMessageChange', callback: Callback&lt;string&gt;): void;
Z
zengyawen 已提交
317 318 319

Registers a listener for GNSS NMEA message change events.

S
shawn_he 已提交
320 321 322 323 324
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('nmeaMessage')](js-apis-geoLocationManager.md#geolocationmanageronnmeamessage).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
325 326 327

**System capability**: SystemCapability.Location.Location.Gnss

L
liu-binjun 已提交
328 329
**Parameters**

330
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
331
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
332 333 334
  | type | string | Yes| Event type. The value **nmeaMessageChange** indicates a GNSS NMEA message change.|
  | callback | Callback&lt;string&gt; | Yes| Callback used to return GNSS NMEA message changes.|

Z
zengyawen 已提交
335

L
liu-binjun 已提交
336
**Example**
S
shawn_he 已提交
337 338

  ```ts
L
liu-binjun 已提交
339
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
340
  var nmeaCb = (str) => {
L
liu-binjun 已提交
341
      console.log('nmeaMessageChange: ' + JSON.stringify(str));
Z
zengyawen 已提交
342 343 344 345 346
  }
  geolocation.on('nmeaMessageChange', nmeaCb );
  ```


S
shawn_he 已提交
347
## geolocation.off('nmeaMessageChange')<sup>(deprecated) </sup>
Z
zengyawen 已提交
348

L
liu-binjun 已提交
349
off(type: 'nmeaMessageChange', callback?: Callback&lt;string&gt;): void;
Z
zengyawen 已提交
350 351 352

Unregisters the listener for GNSS NMEA message change events.

S
shawn_he 已提交
353 354 355 356 357
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('nmeaMessage')](js-apis-geoLocationManager.md#geolocationmanageroffnmeamessage).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
358 359 360

**System capability**: SystemCapability.Location.Location.Gnss

L
liu-binjun 已提交
361 362
**Parameters**

363
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
364
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
365
  | type | string | Yes| Event type. The value **nmeaMessageChange** indicates a GNSS NMEA message change.|
S
shawn_he 已提交
366
  | callback | Callback&lt;string&gt; | No| Callback to unregister. If this parameter is not specified, all callbacks of the specified event type are unregistered.|
S
shawn_he 已提交
367

Z
zengyawen 已提交
368

L
liu-binjun 已提交
369
**Example**
S
shawn_he 已提交
370 371

  ```ts
L
liu-binjun 已提交
372
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
373
  var nmeaCb = (str) => {
L
liu-binjun 已提交
374
      console.log('nmeaMessageChange: ' + JSON.stringify(str));
Z
zengyawen 已提交
375 376 377 378 379 380
  }
  geolocation.on('nmeaMessageChange', nmeaCb);
  geolocation.off('nmeaMessageChange', nmeaCb);
  ```


S
shawn_he 已提交
381
## geolocation.on('fenceStatusChange')<sup>(deprecated) </sup>
Z
zengyawen 已提交
382

L
liu-binjun 已提交
383
on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;
Z
zengyawen 已提交
384 385 386

Registers a listener for status change events of the specified geofence.

S
shawn_he 已提交
387 388 389 390 391
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('gnssFenceStatusChange')](js-apis-geoLocationManager.md#geolocationmanagerongnssfencestatuschange).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
392 393 394

**System capability**: SystemCapability.Location.Location.Geofence

L
liu-binjun 已提交
395 396
**Parameters**

397
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
398
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
399
  | type | string | Yes| Event type. The value **fenceStatusChange** indicates a geofence status change.|
S
shawn_he 已提交
400
  | request |  [GeofenceRequest](#geofencerequest) | Yes| Geofencing request.|
S
shawn_he 已提交
401 402
  | want | WantAgent | Yes| **WantAgent** used to return geofence (entrance or exit) events.|

Z
zengyawen 已提交
403

L
liu-binjun 已提交
404
**Example**
S
shawn_he 已提交
405 406

  ```ts
L
liu-binjun 已提交
407 408 409 410
  import geolocation from '@ohos.geolocation';
  import wantAgent from '@ohos.wantAgent';
  
  let wantAgentInfo = {
Z
zengyawen 已提交
411 412
      wants: [
          {
L
liu-binjun 已提交
413
              bundleName: "com.example.myapplication",
L
liu-binjun 已提交
414
              abilityName: "com.example.myapplication.MainAbility",
Z
zengyawen 已提交
415 416 417
              action: "action1",
          }
      ],
L
liu-binjun 已提交
418
      operationType: wantAgent.OperationType.START_ABILITY,
Z
zengyawen 已提交
419
      requestCode: 0,
L
liu-binjun 已提交
420
      wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG],
L
liu-binjun 已提交
421 422 423 424 425 426
  };
  
  wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
    var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}};
    geolocation.on('fenceStatusChange', requestInfo, wantAgentObj);
  });
Z
zengyawen 已提交
427 428 429
  ```


S
shawn_he 已提交
430
## geolocation.off('fenceStatusChange')<sup>(deprecated) </sup>
Z
zengyawen 已提交
431

L
liu-binjun 已提交
432
off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;
Z
zengyawen 已提交
433 434 435

Unregisters the listener for status change events of the specified geofence.

S
shawn_he 已提交
436 437 438 439 440
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('gnssFenceStatusChange')](js-apis-geoLocationManager.md#geolocationmanageroffgnssfencestatuschange).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
441 442 443

**System capability**: SystemCapability.Location.Location.Geofence

L
liu-binjun 已提交
444 445
**Parameters**

446
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
447
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
448
  | type | string | Yes| Event type. The value **fenceStatusChange** indicates a geofence status change.|
S
shawn_he 已提交
449
  | request | [GeofenceRequest](#geofencerequest) | Yes| Geofencing request.|
S
shawn_he 已提交
450
  | want | WantAgent | Yes| **WantAgent** used to return geofence (entrance or exit) events.|
Z
zengyawen 已提交
451

L
liu-binjun 已提交
452
**Example**
S
shawn_he 已提交
453 454

  ```ts
L
liu-binjun 已提交
455 456 457 458
  import geolocation from '@ohos.geolocation';
  import wantAgent from '@ohos.wantAgent';
  
  let wantAgentInfo = {
Z
zengyawen 已提交
459 460
      wants: [
          {
L
liu-binjun 已提交
461
              bundleName: "com.example.myapplication",
L
liu-binjun 已提交
462
              abilityName: "com.example.myapplication.MainAbility",
Z
zengyawen 已提交
463 464 465
              action: "action1",
          }
      ],
L
liu-binjun 已提交
466
      operationType: wantAgent.OperationType.START_ABILITY,
Z
zengyawen 已提交
467
      requestCode: 0,
L
liu-binjun 已提交
468 469 470 471 472 473 474 475 476 477 478
      wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
  };
  
  wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
    var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}};
    geolocation.on('fenceStatusChange', requestInfo, wantAgentObj);
    geolocation.off('fenceStatusChange', requestInfo, wantAgentObj);
  });
  ```


S
shawn_he 已提交
479
## geolocation.getCurrentLocation<sup>(deprecated) </sup>
Z
zengyawen 已提交
480

L
liu-binjun 已提交
481
getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback&lt;Location&gt;): void
Z
zengyawen 已提交
482

S
shawn_he 已提交
483
Obtains the current location. This API uses an asynchronous callback to return the result. 
Z
zengyawen 已提交
484

S
shawn_he 已提交
485 486 487 488
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
489 490

**System capability**: SystemCapability.Location.Location.Core
Z
zengyawen 已提交
491

L
liu-binjun 已提交
492 493
**Parameters**

494
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
495
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
496
  | request | [CurrentLocationRequest](#currentlocationrequest) | Yes| Location request.|
S
shawn_he 已提交
497
  | callback | AsyncCallback&lt;[Location](#location)&gt; | Yes| Callback used to return the current location.|
Z
zengyawen 已提交
498

L
liu-binjun 已提交
499
**Example**
S
shawn_he 已提交
500 501

  ```ts
L
liu-binjun 已提交
502
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
503 504
  var requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0};
  var locationChange = (err, location) => {
L
liu-binjun 已提交
505 506 507 508 509 510
      if (err) {
          console.log('locationChanger: err=' + JSON.stringify(err));
      }
      if (location) {
          console.log('locationChanger: location=' + JSON.stringify(location));
      }
Z
zengyawen 已提交
511 512
  };
  geolocation.getCurrentLocation(requestInfo, locationChange);
S
shawn_he 已提交
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
  ```


## geolocation.getCurrentLocation<sup>(deprecated) </sup>

getCurrentLocation(callback: AsyncCallback&lt;Location&gt;): void


Obtains the current location. This API uses an asynchronous callback to return the result. 

> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation).

**Required permissions**: ohos.permission.LOCATION

**System capability**: SystemCapability.Location.Location.Core

**Parameters**

  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | callback | AsyncCallback&lt;[Location](#location)&gt; | Yes| Callback used to return the current location.|

**Example**

  ```ts
  import geolocation from '@ohos.geolocation';
  var locationChange = (err, location) => {
      if (err) {
          console.log('locationChanger: err=' + JSON.stringify(err));
      }
      if (location) {
          console.log('locationChanger: location=' + JSON.stringify(location));
      }
  };
Z
zengyawen 已提交
548 549 550 551
  geolocation.getCurrentLocation(locationChange);
  ```


S
shawn_he 已提交
552
## geolocation.getCurrentLocation<sup>(deprecated) </sup>
Z
zengyawen 已提交
553

L
liu-binjun 已提交
554
getCurrentLocation(request?: CurrentLocationRequest): Promise&lt;Location&gt;
Z
zengyawen 已提交
555

S
shawn_he 已提交
556 557
Obtains the current location. This API uses a promise to return the result. 

S
shawn_he 已提交
558 559 560 561
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation-2).

**Required permissions**: ohos.permission.LOCATION
Z
zengyawen 已提交
562

S
shawn_he 已提交
563
**System capability**: SystemCapability.Location.Location.Core
Z
zengyawen 已提交
564

L
liu-binjun 已提交
565 566
**Parameters**

567
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
568
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
569
  | request | [CurrentLocationRequest](#currentlocationrequest) | No| Location request.|
Z
zengyawen 已提交
570

L
liu-binjun 已提交
571 572
**Return value**

S
shawn_he 已提交
573 574 575
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | Promise&lt;[Location](#location)&gt; |[Location](#location)|NA| Promise used to return the current location.|
S
shawn_he 已提交
576

Z
zengyawen 已提交
577

L
liu-binjun 已提交
578
**Example**
S
shawn_he 已提交
579 580

  ```ts
L
liu-binjun 已提交
581
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
582
  var requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0};
L
liu-binjun 已提交
583
  geolocation.getCurrentLocation(requestInfo).then((result) => {
Z
zengyawen 已提交
584 585 586 587 588
      console.log('current location: ' + JSON.stringify(result));
  });
  ```


S
shawn_he 已提交
589
## geolocation.getLastLocation<sup>(deprecated) </sup>
Z
zengyawen 已提交
590

L
liu-binjun 已提交
591
getLastLocation(callback: AsyncCallback&lt;Location&gt;): void
Z
zengyawen 已提交
592

S
shawn_he 已提交
593 594
Obtains the previous location. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
595 596 597 598
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getLastLocation](js-apis-geoLocationManager.md#geolocationmanagergetlastlocation).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
599 600

**System capability**: SystemCapability.Location.Location.Core
Z
zengyawen 已提交
601

L
liu-binjun 已提交
602 603
**Parameters**

604
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
605
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
606 607
  | callback | AsyncCallback&lt;[Location](#location)&gt; | Yes| Callback used to return the previous location.|

Z
zengyawen 已提交
608

L
liu-binjun 已提交
609
**Example**
S
shawn_he 已提交
610 611

  ```ts
L
liu-binjun 已提交
612
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
613
  geolocation.getLastLocation((err, data) => {
L
liu-binjun 已提交
614 615 616 617 618 619
      if (err) {
          console.log('getLastLocation: err=' + JSON.stringify(err));
      }
      if (data) {
          console.log('getLastLocation: data=' + JSON.stringify(data));
      }
Z
zengyawen 已提交
620 621 622 623
  });
  ```


S
shawn_he 已提交
624
## geolocation.getLastLocation<sup>(deprecated) </sup>
Z
zengyawen 已提交
625

L
liu-binjun 已提交
626
getLastLocation(): Promise&lt;Location&gt;
Z
zengyawen 已提交
627

S
shawn_he 已提交
628
Obtains the previous location. This API uses a promise to return the result. 
Z
zengyawen 已提交
629

S
shawn_he 已提交
630 631 632 633
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getLastLocation](js-apis-geoLocationManager.md#geolocationmanagergetlastlocation).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
634 635 636

**System capability**: SystemCapability.Location.Location.Core

L
liu-binjun 已提交
637 638
**Return value**

S
shawn_he 已提交
639 640 641
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | Promise&lt;[Location](#location)&gt; | [Location](#location)|NA|Promise used to return the previous location.|
S
shawn_he 已提交
642

Z
zengyawen 已提交
643

L
liu-binjun 已提交
644
**Example**
S
shawn_he 已提交
645 646

  ```ts
L
liu-binjun 已提交
647
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
648 649 650 651 652 653
  geolocation.getLastLocation().then((result) => {
      console.log('getLastLocation: result: ' + JSON.stringify(result));
  });
  ```


S
shawn_he 已提交
654
## geolocation.isLocationEnabled<sup>(deprecated) </sup>
Z
zengyawen 已提交
655

L
liu-binjun 已提交
656
isLocationEnabled(callback: AsyncCallback&lt;boolean&gt;): void
Z
zengyawen 已提交
657

S
shawn_he 已提交
658
Checks whether the location service is enabled. This API uses an asynchronous callback to return the result.
Z
zengyawen 已提交
659

S
shawn_he 已提交
660 661 662 663
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isLocationEnabled](js-apis-geoLocationManager.md#geolocationmanagerislocationenabled).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
664 665

**System capability**: SystemCapability.Location.Location.Core
Z
zengyawen 已提交
666

L
liu-binjun 已提交
667 668
**Parameters**

669
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
670
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
671 672
  | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the location service status.|

L
liu-binjun 已提交
673
**Example**
S
shawn_he 已提交
674 675

  ```ts
L
liu-binjun 已提交
676
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
677
  geolocation.isLocationEnabled((err, data) => {
L
liu-binjun 已提交
678 679 680 681 682 683
      if (err) {
          console.log('isLocationEnabled: err=' + JSON.stringify(err));
      }
      if (data) {
          console.log('isLocationEnabled: data=' + JSON.stringify(data));
      }
Z
zengyawen 已提交
684 685 686 687
  });
  ```


S
shawn_he 已提交
688
## geolocation.isLocationEnabled<sup>(deprecated) </sup>
Z
zengyawen 已提交
689

L
liu-binjun 已提交
690
isLocationEnabled(): Promise&lt;boolean&gt;
Z
zengyawen 已提交
691

S
shawn_he 已提交
692 693
Checks whether the location service is enabled. This API uses a promise to return the result.

S
shawn_he 已提交
694 695 696 697
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isLocationEnabled](js-apis-geoLocationManager.md#geolocationmanagerislocationenabled).

**Required permissions**: ohos.permission.LOCATION
Z
zengyawen 已提交
698

S
shawn_he 已提交
699 700
**System capability**: SystemCapability.Location.Location.Core

L
liu-binjun 已提交
701 702
**Return value**

S
shawn_he 已提交
703 704 705
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | Promise&lt;boolean&gt; | boolean|NA|Promise used to return the location service status.|
Z
zengyawen 已提交
706

L
liu-binjun 已提交
707
**Example**
S
shawn_he 已提交
708 709

  ```ts
L
liu-binjun 已提交
710
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
711
  geolocation.isLocationEnabled().then((result) => {
L
liu-binjun 已提交
712
      console.log('promise, isLocationEnabled: ' + JSON.stringify(result));
Z
zengyawen 已提交
713 714 715 716
  });
  ```


S
shawn_he 已提交
717
## geolocation.requestEnableLocation<sup>(deprecated) </sup>
Z
zengyawen 已提交
718

L
liu-binjun 已提交
719
requestEnableLocation(callback: AsyncCallback&lt;boolean&gt;): void
Z
zengyawen 已提交
720

S
shawn_he 已提交
721 722
Requests to enable the location service. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
723 724 725 726
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.requestEnableLocation](js-apis-geoLocationManager.md#geolocationmanagerrequestenablelocation).

**Required permissions**: ohos.permission.LOCATION
Z
zengyawen 已提交
727

S
shawn_he 已提交
728
**System capability**: SystemCapability.Location.Location.Core
Z
zengyawen 已提交
729

L
liu-binjun 已提交
730 731
**Parameters**

732
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
733
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
734 735
  | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the location service status.|

L
liu-binjun 已提交
736
**Example**
S
shawn_he 已提交
737 738

  ```ts
L
liu-binjun 已提交
739
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
740
  geolocation.requestEnableLocation((err, data) => {
L
liu-binjun 已提交
741 742 743 744 745 746
      if (err) {
          console.log('requestEnableLocation: err=' + JSON.stringify(err));
      }
      if (data) {
          console.log('requestEnableLocation: data=' + JSON.stringify(data));
      }
Z
zengyawen 已提交
747 748 749 750
  });
  ```


S
shawn_he 已提交
751
## geolocation.requestEnableLocation<sup>(deprecated) </sup>
Z
zengyawen 已提交
752

L
liu-binjun 已提交
753
requestEnableLocation(): Promise&lt;boolean&gt;
Z
zengyawen 已提交
754

S
shawn_he 已提交
755
Requests to enable the location service. This API uses a promise to return the result.
Z
zengyawen 已提交
756

S
shawn_he 已提交
757 758
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.requestEnableLocation](js-apis-geoLocationManager.md#geolocationmanagerrequestenablelocation-1).
S
shawn_he 已提交
759

S
shawn_he 已提交
760
**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
761 762 763

**System capability**: SystemCapability.Location.Location.Core

L
liu-binjun 已提交
764 765
**Return value**

766
  | Name| Type| Mandatory| Description|
S
shawn_he 已提交
767
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
768
  | Promise&lt;boolean&gt; | boolean|NA|Promise used to return the location service status.|
S
shawn_he 已提交
769

L
liu-binjun 已提交
770
**Example**
S
shawn_he 已提交
771

S
shawn_he 已提交
772
  ```ts
L
liu-binjun 已提交
773
  import geolocation from '@ohos.geolocation';
S
shawn_he 已提交
774 775
  geolocation.requestEnableLocation().then((result) => {
      console.log('promise, requestEnableLocation: ' + JSON.stringify(result));
S
shawn_he 已提交
776 777 778
  });
  ```

S
shawn_he 已提交
779 780

## geolocation.isGeoServiceAvailable<sup>(deprecated) </sup>
Z
zengyawen 已提交
781

L
liu-binjun 已提交
782
isGeoServiceAvailable(callback: AsyncCallback&lt;boolean&gt;): void
Z
zengyawen 已提交
783

S
shawn_he 已提交
784 785
Checks whether the (reverse) geocoding service is available. This API uses an asynchronous callback to return the result.

S
shawn_he 已提交
786 787 788 789
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isGeocoderAvailable](js-apis-geoLocationManager.md#geolocationmanagerisgeocoderavailable).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
790 791

**System capability**: SystemCapability.Location.Location.Geocoder
Z
zengyawen 已提交
792

L
liu-binjun 已提交
793 794
**Parameters**

795
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
796
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
797 798
  | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the (reverse) geocoding service status.|

L
liu-binjun 已提交
799
**Example**
S
shawn_he 已提交
800 801

  ```ts
L
liu-binjun 已提交
802
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
803
  geolocation.isGeoServiceAvailable((err, data) => {
L
liu-binjun 已提交
804 805 806 807 808 809
      if (err) {
          console.log('isGeoServiceAvailable: err=' + JSON.stringify(err));
      }
      if (data) {
          console.log('isGeoServiceAvailable: data=' + JSON.stringify(data));
      }
Z
zengyawen 已提交
810 811 812 813
  });
  ```


S
shawn_he 已提交
814
## geolocation.isGeoServiceAvailable<sup>(deprecated) </sup>
Z
zengyawen 已提交
815

L
liu-binjun 已提交
816
isGeoServiceAvailable(): Promise&lt;boolean&gt;
Z
zengyawen 已提交
817

S
shawn_he 已提交
818 819
Checks whether the (reverse) geocoding service is available. This API uses a promise to return the result.

S
shawn_he 已提交
820 821 822 823
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.isGeocoderAvailable](js-apis-geoLocationManager.md#geolocationmanagerisgeocoderavailable).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
824 825

**System capability**: SystemCapability.Location.Location.Geocoder
Z
zengyawen 已提交
826

L
liu-binjun 已提交
827 828
**Return value**

S
shawn_he 已提交
829 830 831
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | Promise&lt;boolean&gt; |boolean|NA| Promise used to return the (reverse) geocoding service status.|
S
shawn_he 已提交
832

L
liu-binjun 已提交
833
**Example**
S
shawn_he 已提交
834 835

  ```ts
L
liu-binjun 已提交
836
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
837
  geolocation.isGeoServiceAvailable().then((result) => {
L
liu-binjun 已提交
838
      console.log('promise, isGeoServiceAvailable: ' + JSON.stringify(result));
Z
zengyawen 已提交
839 840 841 842
  });
  ```


S
shawn_he 已提交
843
## geolocation.getAddressesFromLocation<sup>(deprecated) </sup>
Z
zengyawen 已提交
844

L
liu-binjun 已提交
845
getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;): void
Z
zengyawen 已提交
846

S
shawn_he 已提交
847 848
Converts coordinates into geographic description through reverse geocoding. This API uses an asynchronous callback to return the result. 

S
shawn_he 已提交
849 850 851 852
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocation](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocation).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
853 854

**System capability**: SystemCapability.Location.Location.Geocoder
Z
zengyawen 已提交
855

L
liu-binjun 已提交
856 857
**Parameters**

858
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
859
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
860 861
  | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Reverse geocoding request.|
  | callback | AsyncCallback&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Yes| Callback used to return the reverse geocoding result.|
Z
zengyawen 已提交
862

L
liu-binjun 已提交
863
**Example**
S
shawn_he 已提交
864 865

  ```ts
L
liu-binjun 已提交
866
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
867 868
  var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1};
  geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => {
L
liu-binjun 已提交
869 870 871 872 873 874
      if (err) {
          console.log('getAddressesFromLocation: err=' + JSON.stringify(err));
      }
      if (data) {
          console.log('getAddressesFromLocation: data=' + JSON.stringify(data));
      }
Z
zengyawen 已提交
875 876 877 878
  });
  ```


S
shawn_he 已提交
879
## geolocation.getAddressesFromLocation<sup>(deprecated) </sup>
Z
zengyawen 已提交
880

L
liu-binjun 已提交
881
getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise&lt;Array&lt;GeoAddress&gt;&gt;;
Z
zengyawen 已提交
882

S
shawn_he 已提交
883 884
Converts coordinates into geographic description through reverse geocoding. This API uses a promise to return the result. 

S
shawn_he 已提交
885 886 887 888
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocation](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocation-1).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
889 890

**System capability**: SystemCapability.Location.Location.Geocoder
Z
zengyawen 已提交
891

L
liu-binjun 已提交
892 893
**Parameters**

894
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
895
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
896
  | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Reverse geocoding request.|
Z
zengyawen 已提交
897

L
liu-binjun 已提交
898 899
**Return value**

S
shawn_he 已提交
900 901 902
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | Promise&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Array&lt;[GeoAddress](#geoaddress)&gt;|NA|Promise used to return the reverse geocoding result.|
Z
zengyawen 已提交
903

L
liu-binjun 已提交
904
**Example**
S
shawn_he 已提交
905 906

  ```ts
L
liu-binjun 已提交
907
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
908 909 910 911 912 913 914
  var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1};
  geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => {
      console.log('getAddressesFromLocation: ' + JSON.stringify(data));
  });
  ```


S
shawn_he 已提交
915
## geolocation.getAddressesFromLocationName<sup>(deprecated) </sup>
Z
zengyawen 已提交
916

L
liu-binjun 已提交
917
getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;): void
Z
zengyawen 已提交
918

S
shawn_he 已提交
919 920
Converts geographic description into coordinates through geocoding. This API uses an asynchronous callback to return the result. 

S
shawn_he 已提交
921 922 923 924
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocationName](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocationname).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
925 926

**System capability**: SystemCapability.Location.Location.Geocoder
Z
zengyawen 已提交
927

L
liu-binjun 已提交
928 929
**Parameters**

930
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
931
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
932 933 934
  | request | [GeoCodeRequest](#geocoderequest) | Yes| Geocoding request.|
  | callback | AsyncCallback&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Yes| Callback used to return the geocoding result.|

L
liu-binjun 已提交
935
**Example**
S
shawn_he 已提交
936 937

  ```ts
L
liu-binjun 已提交
938
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
939 940
  var geocodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1};
  geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => {
L
liu-binjun 已提交
941 942 943 944 945 946
      if (err) {
          console.log('getAddressesFromLocationName: err=' + JSON.stringify(err));
      }
      if (data) {
          console.log('getAddressesFromLocationName: data=' + JSON.stringify(data));
      }
Z
zengyawen 已提交
947 948 949 950
  });
  ```


S
shawn_he 已提交
951
## geolocation.getAddressesFromLocationName<sup>(deprecated) </sup>
Z
zengyawen 已提交
952

L
liu-binjun 已提交
953
getAddressesFromLocationName(request: GeoCodeRequest): Promise&lt;Array&lt;GeoAddress&gt;&gt;
Z
zengyawen 已提交
954

S
shawn_he 已提交
955 956
Converts geographic description into coordinates through geocoding. This API uses a promise to return the result. 

S
shawn_he 已提交
957 958 959 960
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getAddressesFromLocationName](js-apis-geoLocationManager.md#geolocationmanagergetaddressesfromlocationname-1).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
961 962

**System capability**: SystemCapability.Location.Location.Geocoder
Z
zengyawen 已提交
963

L
liu-binjun 已提交
964 965
**Parameters**

966
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
967
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
968
  | request | [GeoCodeRequest](#geocoderequest) | Yes| Geocoding request.|
Z
zengyawen 已提交
969

L
liu-binjun 已提交
970 971
**Return value**

S
shawn_he 已提交
972 973
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
974
  | Promise&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Array&lt;[GeoAddress](#geoaddress)&gt;|NA|Promise used to return the geocoding result.|
Z
zengyawen 已提交
975

L
liu-binjun 已提交
976
**Example**
S
shawn_he 已提交
977 978

  ```ts
L
liu-binjun 已提交
979
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
980 981 982 983 984 985 986
  var geocodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1};
  geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
      console.log('getAddressesFromLocationName: ' + JSON.stringify(result));
  });
  ```


S
shawn_he 已提交
987
## geolocation.getCachedGnssLocationsSize<sup>(deprecated) </sup>
Z
zengyawen 已提交
988

L
liu-binjun 已提交
989
getCachedGnssLocationsSize(callback: AsyncCallback&lt;number&gt;): void;
Z
zengyawen 已提交
990

S
shawn_he 已提交
991 992
Obtains the number of cached GNSS locations. 

S
shawn_he 已提交
993 994 995 996 997
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCachedGnssLocationsSize](js-apis-geoLocationManager.md#geolocationmanagergetcachedgnsslocationssize).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
998 999

**System capability**: SystemCapability.Location.Location.Gnss
Z
zengyawen 已提交
1000

L
liu-binjun 已提交
1001 1002
**Parameters**

1003
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
1004
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
1005
  | callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the number of cached GNSS locations. |
Z
zengyawen 已提交
1006

L
liu-binjun 已提交
1007
**Example**
S
shawn_he 已提交
1008 1009

  ```ts
L
liu-binjun 已提交
1010
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
1011
  geolocation.getCachedGnssLocationsSize((err, size) => {
L
liu-binjun 已提交
1012 1013 1014 1015 1016 1017
      if (err) {
          console.log('getCachedGnssLocationsSize: err=' + JSON.stringify(err));
      }
      if (size) {
          console.log('getCachedGnssLocationsSize: size=' + JSON.stringify(size));
      }
Z
zengyawen 已提交
1018 1019 1020 1021
  });
  ```


S
shawn_he 已提交
1022
## geolocation.getCachedGnssLocationsSize<sup>(deprecated) </sup>
Z
zengyawen 已提交
1023

L
liu-binjun 已提交
1024
getCachedGnssLocationsSize(): Promise&lt;number&gt;;
Z
zengyawen 已提交
1025

S
shawn_he 已提交
1026
Obtains the number of cached GNSS locations. 
Z
zengyawen 已提交
1027

S
shawn_he 已提交
1028 1029 1030 1031 1032
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCachedGnssLocationsSize](js-apis-geoLocationManager.md#geolocationmanagergetcachedgnsslocationssize-1).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1033 1034 1035

**System capability**: SystemCapability.Location.Location.Gnss

L
liu-binjun 已提交
1036 1037
**Return value**

S
shawn_he 已提交
1038 1039 1040
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | Promise&lt;number&gt; | number|NA|Promise used to return the number of cached GNSS locations.|
Z
zengyawen 已提交
1041

L
liu-binjun 已提交
1042
**Example**
S
shawn_he 已提交
1043 1044

  ```ts
L
liu-binjun 已提交
1045
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
1046
  geolocation.getCachedGnssLocationsSize().then((result) => {
L
liu-binjun 已提交
1047
      console.log('promise, getCachedGnssLocationsSize: ' + JSON.stringify(result));
Z
zengyawen 已提交
1048 1049 1050 1051
  });
  ```


S
shawn_he 已提交
1052
## geolocation.flushCachedGnssLocations<sup>(deprecated) </sup>
Z
zengyawen 已提交
1053

L
liu-binjun 已提交
1054
flushCachedGnssLocations(callback: AsyncCallback&lt;boolean&gt;): void;
Z
zengyawen 已提交
1055

S
shawn_he 已提交
1056 1057
Obtains all cached GNSS locations and clears the GNSS cache queue. 

S
shawn_he 已提交
1058 1059 1060 1061 1062
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.flushCachedGnssLocations](js-apis-geoLocationManager.md#geolocationmanagerflushcachedgnsslocations).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1063 1064

**System capability**: SystemCapability.Location.Location.Gnss
Z
zengyawen 已提交
1065

L
liu-binjun 已提交
1066 1067
**Parameters**

1068
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
1069
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
1070
  | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the operation result.|
Z
zengyawen 已提交
1071

L
liu-binjun 已提交
1072
**Example**
S
shawn_he 已提交
1073 1074

  ```ts
L
liu-binjun 已提交
1075
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
1076
  geolocation.flushCachedGnssLocations((err, result) => {
L
liu-binjun 已提交
1077 1078 1079 1080 1081 1082
      if (err) {
          console.log('flushCachedGnssLocations: err=' + JSON.stringify(err));
      }
      if (result) {
          console.log('flushCachedGnssLocations: result=' + JSON.stringify(result));
      }
Z
zengyawen 已提交
1083 1084 1085 1086
  });
  ```


S
shawn_he 已提交
1087
## geolocation.flushCachedGnssLocations<sup>(deprecated) </sup>
Z
zengyawen 已提交
1088

L
liu-binjun 已提交
1089
flushCachedGnssLocations(): Promise&lt;boolean&gt;;
Z
zengyawen 已提交
1090

S
shawn_he 已提交
1091 1092
Obtains all cached GNSS locations and clears the GNSS cache queue. 

S
shawn_he 已提交
1093 1094 1095 1096 1097
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.flushCachedGnssLocations](js-apis-geoLocationManager.md#geolocationmanagerflushcachedgnsslocations-1).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1098 1099

**System capability**: SystemCapability.Location.Location.Gnss
Z
zengyawen 已提交
1100

L
liu-binjun 已提交
1101 1102
**Return value**

S
shawn_he 已提交
1103 1104 1105
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | Promise&lt;boolean&gt; |boolean|NA| Promise used to return the operation result.|
Z
zengyawen 已提交
1106

L
liu-binjun 已提交
1107
**Example**
S
shawn_he 已提交
1108 1109

  ```ts
L
liu-binjun 已提交
1110
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
1111
  geolocation.flushCachedGnssLocations().then((result) => {
L
liu-binjun 已提交
1112
      console.log('promise, flushCachedGnssLocations: ' + JSON.stringify(result));
Z
zengyawen 已提交
1113 1114 1115 1116
  });
  ```


S
shawn_he 已提交
1117
## geolocation.sendCommand<sup>(deprecated) </sup>
Z
zengyawen 已提交
1118

L
liu-binjun 已提交
1119
sendCommand(command: LocationCommand, callback: AsyncCallback&lt;boolean&gt;): void;
Z
zengyawen 已提交
1120

S
shawn_he 已提交
1121 1122 1123 1124 1125
Sends an extended command to the location subsystem. 

> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.sendCommand](js-apis-geoLocationManager.md#geolocationmanagersendcommand).
S
shawn_he 已提交
1126

S
shawn_he 已提交
1127
**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1128 1129

**System capability**: SystemCapability.Location.Location.Core
Z
zengyawen 已提交
1130

L
liu-binjun 已提交
1131 1132
**Parameters**

1133
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
1134
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
1135
  | command |  [LocationCommand](#locationcommand) | Yes| Extended command (string) to be sent.|
S
shawn_he 已提交
1136
  | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the operation result.|
Z
zengyawen 已提交
1137

L
liu-binjun 已提交
1138
**Example**
S
shawn_he 已提交
1139 1140

  ```ts
L
liu-binjun 已提交
1141
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
1142 1143
  var requestInfo = {'scenario': 0x301, 'command': "command_1"};
  geolocation.sendCommand(requestInfo, (err, result) => {
L
liu-binjun 已提交
1144 1145 1146 1147 1148 1149
      if (err) {
          console.log('sendCommand: err=' + JSON.stringify(err));
      }
      if (result) {
          console.log('sendCommand: result=' + JSON.stringify(result));
      }
Z
zengyawen 已提交
1150 1151 1152 1153
  });
  ```


S
shawn_he 已提交
1154
## geolocation.sendCommand<sup>(deprecated) </sup>
Z
zengyawen 已提交
1155

L
liu-binjun 已提交
1156
sendCommand(command: LocationCommand): Promise&lt;boolean&gt;;
Z
zengyawen 已提交
1157

S
shawn_he 已提交
1158 1159 1160 1161 1162
Sends an extended command to the location subsystem. 

> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.sendCommand](js-apis-geoLocationManager.md#geolocationmanagersendcommand).
S
shawn_he 已提交
1163

S
shawn_he 已提交
1164
**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1165 1166

**System capability**: SystemCapability.Location.Location.Core
Z
zengyawen 已提交
1167

L
liu-binjun 已提交
1168 1169
**Parameters**

1170
  | Name| Type| Mandatory| Description|
Z
zengyawen 已提交
1171
  | -------- | -------- | -------- | -------- |
S
shawn_he 已提交
1172
  | command | [LocationCommand](#locationcommand) | Yes| Extended command (string) to be sent.|
Z
zengyawen 已提交
1173

L
liu-binjun 已提交
1174 1175
**Return value**

S
shawn_he 已提交
1176 1177 1178
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
  | Promise&lt;boolean&gt; |boolean|NA| Callback used to return the operation result.|
Z
zengyawen 已提交
1179

L
liu-binjun 已提交
1180
**Example**
S
shawn_he 已提交
1181 1182

  ```ts
L
liu-binjun 已提交
1183
  import geolocation from '@ohos.geolocation';
Z
zengyawen 已提交
1184 1185
  var requestInfo = {'scenario': 0x301, 'command': "command_1"};
  geolocation.sendCommand(requestInfo).then((result) => {
L
liu-binjun 已提交
1186
      console.log('promise, sendCommand: ' + JSON.stringify(result));
Z
zengyawen 已提交
1187 1188 1189 1190
  });
  ```


S
shawn_he 已提交
1191
## LocationRequestPriority<sup>(deprecated) </sup>
S
shawn_he 已提交
1192

L
liu-binjun 已提交
1193
Sets the priority of the location request.
S
shawn_he 已提交
1194

S
shawn_he 已提交
1195 1196 1197 1198
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationRequestPriority](js-apis-geoLocationManager.md#locationrequestpriority).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1199 1200

**System capability**: SystemCapability.Location.Location.Core
Z
zengyawen 已提交
1201

S
shawn_he 已提交
1202
| Name| Value| Description|
L
liu-binjun 已提交
1203 1204 1205 1206 1207
| -------- | -------- | -------- |
| UNSET | 0x200 | Priority unspecified.|
| ACCURACY | 0x201 | Location accuracy.|
| LOW_POWER | 0x202 | Power efficiency.|
| FIRST_FIX | 0x203 | Fast location. Use this option if you want to obtain a location as fast as possible.|
L
liu-binjun 已提交
1208

Z
zengyawen 已提交
1209

S
shawn_he 已提交
1210
## LocationRequestScenario<sup>(deprecated) </sup>
L
liu-binjun 已提交
1211 1212 1213

  Sets the scenario of the location request.

S
shawn_he 已提交
1214 1215 1216 1217
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationRequestScenario](js-apis-geoLocationManager.md#locationrequestscenario).

**Required permissions**: ohos.permission.LOCATION
Z
zengyawen 已提交
1218

L
liu-binjun 已提交
1219
**System capability**: SystemCapability.Location.Location.Core
Z
zengyawen 已提交
1220

S
shawn_he 已提交
1221
| Name| Value| Description|
L
liu-binjun 已提交
1222 1223 1224 1225 1226 1227 1228
| -------- | -------- | -------- |
| UNSET | 0x300 | Scenario unspecified.|
| NAVIGATION | 0x301 | Navigation.|
| TRAJECTORY_TRACKING | 0x302 | Trajectory tracking.|
| CAR_HAILING | 0x303 | Ride hailing.|
| DAILY_LIFE_SERVICE | 0x304 | Daily life services.|
| NO_POWER | 0x305 | Power efficiency. Your application does not proactively start the location service. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.|
Z
zengyawen 已提交
1229 1230


S
shawn_he 已提交
1231
## GeoLocationErrorCode<sup>(deprecated) </sup>
S
shawn_he 已提交
1232

L
liu-binjun 已提交
1233
Enumerates error codes of the location service.
S
shawn_he 已提交
1234

S
shawn_he 已提交
1235 1236 1237 1238
> **NOTE**
> This API is deprecated since API version 9.

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1239 1240

**System capability**: SystemCapability.Location.Location.Core
Z
zengyawen 已提交
1241

S
shawn_he 已提交
1242
| Name| Value| Description|
L
liu-binjun 已提交
1243 1244 1245 1246 1247 1248 1249 1250
| -------- | -------- | -------- |
| INPUT_PARAMS_ERROR<sup>7+</sup> | 101 | Incorrect input parameters.|
| REVERSE_GEOCODE_ERROR<sup>7+</sup> | 102 | Failed to call the reverse geocoding API.|
| GEOCODE_ERROR<sup>7+</sup> | 103 | Failed to call the geocoding API.|
| LOCATOR_ERROR<sup>7+</sup> | 104 | Failed to obtain the location.|
| LOCATION_SWITCH_ERROR<sup>7+</sup> | 105 | Failed to change the location service switch.|
| LAST_KNOWN_LOCATION_ERROR<sup>7+</sup> | 106 | Failed to obtain the previous location.|
| LOCATION_REQUEST_TIMEOUT_ERROR<sup>7+</sup> | 107 | Failed to obtain the location within the specified time.|
L
liu-binjun 已提交
1251

Z
zengyawen 已提交
1252

S
shawn_he 已提交
1253
## ReverseGeoCodeRequest<sup>(deprecated) </sup>
L
liu-binjun 已提交
1254

L
liu-binjun 已提交
1255
Defines a reverse geocoding request.
Z
zengyawen 已提交
1256

S
shawn_he 已提交
1257 1258 1259 1260
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.ReverseGeoCodeRequest](js-apis-geoLocationManager.md#reversegeocoderequest).

**Required permissions**: ohos.permission.LOCATION
Z
zengyawen 已提交
1261

L
liu-binjun 已提交
1262
**System capability**: SystemCapability.Location.Location.Geocoder
Z
zengyawen 已提交
1263

S
shawn_he 已提交
1264 1265 1266 1267
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| locale | string | Yes| Yes| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| latitude | number | Yes| Yes| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.|
S
shawn_he 已提交
1268
| longitude | number | Yes| Yes| Longitude information. A positive value indicates east longitude, and a negative value indicates west longitude.|
S
shawn_he 已提交
1269
| maxItems | number | Yes| Yes| Maximum number of location records to be returned.|
Z
zengyawen 已提交
1270 1271


S
shawn_he 已提交
1272
## GeoCodeRequest<sup>(deprecated) </sup>
S
shawn_he 已提交
1273

L
liu-binjun 已提交
1274
Defines a geocoding request.
S
shawn_he 已提交
1275

S
shawn_he 已提交
1276 1277 1278 1279
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.GeoCodeRequest](js-apis-geoLocationManager.md#geocoderequest).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1280

L
liu-binjun 已提交
1281
**System capability**: SystemCapability.Location.Location.Geocoder
Z
zengyawen 已提交
1282

S
shawn_he 已提交
1283 1284 1285 1286 1287 1288 1289 1290 1291
| Name| Type| Readable|Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| locale | string | Yes| Yes| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| description | string | Yes| Yes| Location description, for example, **No. xx, xx Road, Pudong New District, Shanghai**.|
| maxItems | number | Yes| Yes| Maximum number of location records to be returned.|
| minLatitude | number | Yes| Yes| Minimum latitude. This parameter is used with **minLongitude**, **maxLatitude**, and **maxLongitude** to specify the latitude and longitude ranges.|
| minLongitude | number | Yes| Yes| Minimum longitude.|
| maxLatitude | number | Yes| Yes| Maximum latitude.|
| maxLongitude | number | Yes| Yes| Maximum longitude.|
L
liu-binjun 已提交
1292

Z
zengyawen 已提交
1293

S
shawn_he 已提交
1294
## GeoAddress<sup>(deprecated) </sup>
L
liu-binjun 已提交
1295 1296 1297

Defines a geographic location.

S
shawn_he 已提交
1298 1299 1300 1301
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.GeoAddress](js-apis-geoLocationManager.md#geoaddress).

**Required permissions**: ohos.permission.LOCATION
Z
zengyawen 已提交
1302

L
liu-binjun 已提交
1303
**System capability**: SystemCapability.Location.Location.Geocoder
Z
zengyawen 已提交
1304

S
shawn_he 已提交
1305 1306 1307
| Name| Type| Readable|Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| latitude<sup>7+</sup> | number | Yes| No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.|
S
shawn_he 已提交
1308
| longitude<sup>7+</sup> | number | Yes| No| Longitude information. A positive value indicates east longitude, and a negative value indicates west longitude.|
S
shawn_he 已提交
1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327
| locale<sup>7+</sup> | string | Yes| No| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
| placeName<sup>7+</sup> | string | Yes| No| Landmark of the location.|
| countryCode<sup>7+</sup> | string | Yes| No| Country code.|
| countryName<sup>7+</sup> | string | Yes| No| Country name.|
| administrativeArea<sup>7+</sup> | string | Yes| No| Administrative region name.|
| subAdministrativeArea<sup>7+</sup> | string | Yes| No| Sub-administrative region name.|
| locality<sup>7+</sup> | string | Yes| No| Locality information.|
| subLocality<sup>7+</sup> | string | Yes| No| Sub-locality information.|
| roadName<sup>7+</sup> | string | Yes| No| Road name.|
| subRoadName<sup>7+</sup> | string | Yes| No| Auxiliary road information.|
| premises<sup>7+</sup> | string | Yes| No| House information.|
| postalCode<sup>7+</sup> | string | Yes| No| Postal code.|
| phoneNumber<sup>7+</sup> | string | Yes| No| Phone number.|
| addressUrl<sup>7+</sup> | string | Yes| No| Website URL.|
| descriptions<sup>7+</sup> | Array&lt;string&gt; | Yes| No| Additional descriptions.|
| descriptionsSize<sup>7+</sup> | number | Yes| No| Total number of additional descriptions.|


## LocationRequest<sup>(deprecated) </sup>
S
shawn_he 已提交
1328

L
liu-binjun 已提交
1329
Defines a location request.
S
shawn_he 已提交
1330

S
shawn_he 已提交
1331 1332 1333 1334
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationRequest](js-apis-geoLocationManager.md#locationrequest).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1335 1336

**System capability**: SystemCapability.Location.Location.Core
Z
zengyawen 已提交
1337

S
shawn_he 已提交
1338 1339 1340 1341 1342 1343 1344
| Name| Type| Readable|Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| priority | [LocationRequestPriority](#locationrequestpriority) | Yes| Yes| Priority of the location request.|
| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes| Yes| Scenario of the location request.|
| timeInterval | number | Yes| Yes| Time interval at which location information is reported.|
| distanceInterval | number | Yes| Yes| Distance interval at which location information is reported.|
| maxAccuracy | number | Yes| Yes| Location accuracy. This parameter is valid only when the precise location function is enabled, and is invalid when the approximate location function is enabled.|
L
liu-binjun 已提交
1345

Z
zengyawen 已提交
1346

S
shawn_he 已提交
1347
## CurrentLocationRequest<sup>(deprecated) </sup>
L
liu-binjun 已提交
1348

L
liu-binjun 已提交
1349
Defines the current location request.
Z
zengyawen 已提交
1350

S
shawn_he 已提交
1351 1352 1353 1354
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CurrentLocationRequest](js-apis-geoLocationManager.md#currentlocationrequest).

**Required permissions**: ohos.permission.LOCATION
L
liu-binjun 已提交
1355

L
liu-binjun 已提交
1356
**System capability**: SystemCapability.Location.Location.Core
L
liu-binjun 已提交
1357

S
shawn_he 已提交
1358 1359 1360 1361 1362 1363
| Name| Type| Readable|Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| priority | [LocationRequestPriority](#locationrequestpriority) | Yes| Yes| Priority of the location request.|
| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes| Yes| Scenario of the location request.|
| maxAccuracy | number | Yes| Yes| Location accuracy, in meters. This parameter is valid only when the precise location function is enabled, and is invalid when the approximate location function is enabled.|
| timeoutMs | number | Yes| Yes| Timeout duration, in milliseconds. The minimum value is **1000**.|
L
liu-binjun 已提交
1364 1365


S
shawn_he 已提交
1366
## SatelliteStatusInfo<sup>(deprecated) </sup>
L
liu-binjun 已提交
1367

L
liu-binjun 已提交
1368
Defines the satellite status information.
L
liu-binjun 已提交
1369

S
shawn_he 已提交
1370 1371 1372 1373 1374
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.SatelliteStatusInfo](js-apis-geoLocationManager.md#satellitestatusinfo).

**Required permissions**: ohos.permission.LOCATION
L
liu-binjun 已提交
1375

L
liu-binjun 已提交
1376
**System capability**: SystemCapability.Location.Location.Gnss
L
liu-binjun 已提交
1377

S
shawn_he 已提交
1378 1379 1380 1381 1382 1383 1384 1385
| Name| Type| Readable|Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| satellitesNumber | number | Yes| No| Number of satellites.|
| satelliteIds | Array&lt;number&gt; | Yes| No| Array of satellite IDs.|
| carrierToNoiseDensitys | Array&lt;number&gt; | Yes| No| Carrier-to-noise density ratio, that is, **cn0**.|
| altitudes | Array&lt;number&gt; | Yes| No| Altitude information.|
| azimuths | Array&lt;number&gt; | Yes| No| Azimuth information.|
| carrierFrequencies | Array&lt;number&gt; | Yes| No| Carrier frequency.|
L
liu-binjun 已提交
1386 1387


S
shawn_he 已提交
1388
## CachedGnssLocationsRequest<sup>(deprecated) </sup>
L
liu-binjun 已提交
1389

L
liu-binjun 已提交
1390
Represents a request for reporting cached GNSS locations.
L
liu-binjun 已提交
1391

S
shawn_he 已提交
1392 1393 1394 1395 1396
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CachedGnssLocationsRequest](js-apis-geoLocationManager.md#cachedgnsslocationsrequest).

**Required permissions**: ohos.permission.LOCATION
L
liu-binjun 已提交
1397

L
liu-binjun 已提交
1398
**System capability**: SystemCapability.Location.Location.Gnss
S
shawn_he 已提交
1399

S
shawn_he 已提交
1400 1401 1402 1403
| Name| Type| Readable|Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| reportingPeriodSec | number | Yes| Yes| Interval for reporting the cached GNSS locations, in milliseconds.|
| wakeUpCacheQueueFull | boolean | Yes| Yes | **true**: reports the cached GNSS locations to the application when the cache queue is full.<br>**false**: discards the cached GNSS locations when the cache queue is full.|
Z
zengyawen 已提交
1404 1405


S
shawn_he 已提交
1406
## Geofence<sup>(deprecated) </sup>
Z
zengyawen 已提交
1407 1408 1409

Defines a GNSS geofence. Currently, only circular geofences are supported.

S
shawn_he 已提交
1410 1411 1412 1413 1414
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.Geofence](js-apis-geoLocationManager.md#geofence).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1415 1416 1417

**System capability**: SystemCapability.Location.Location.Geofence

S
shawn_he 已提交
1418 1419 1420 1421 1422 1423
| Name| Type| Readable|Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| latitude | number | Yes| Yes | Latitude information.|
| longitude | number | Yes| Yes | Longitude information.|
| radius | number | Yes| Yes | Radius of a circular geofence.|
| expiration | number | Yes| Yes | Expiration period of a geofence, in milliseconds.|
Z
zengyawen 已提交
1424 1425


S
shawn_he 已提交
1426
## GeofenceRequest<sup>(deprecated) </sup>
Z
zengyawen 已提交
1427 1428 1429

Represents a GNSS geofencing request.

S
shawn_he 已提交
1430 1431 1432 1433 1434
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.GeofenceRequest](js-apis-geoLocationManager.md#geofencerequest).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1435 1436 1437

**System capability**: SystemCapability.Location.Location.Geofence

S
shawn_he 已提交
1438 1439 1440 1441 1442
| Name| Type| Readable|Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| priority | [LocationRequestPriority](#locationrequestpriority) | Yes| Yes | Priority of the location information.|
| scenario | [LocationRequestScenario](#locationrequestscenario) | Yes| Yes | Location scenario.|
| geofence | [Geofence](#geofence)| Yes| Yes | Geofence information.|
Z
zengyawen 已提交
1443 1444


S
shawn_he 已提交
1445
## LocationPrivacyType<sup>(deprecated) </sup>
Z
zengyawen 已提交
1446 1447 1448

Defines the privacy statement type.

S
shawn_he 已提交
1449 1450 1451 1452 1453
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationPrivacyType](js-apis-geoLocationManager.md#locationprivacytype).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1454 1455 1456

**System capability**: SystemCapability.Location.Location.Core

S
shawn_he 已提交
1457
| Name| Value| Description|
Z
zengyawen 已提交
1458
| -------- | -------- | -------- |
S
shawn_he 已提交
1459 1460 1461
| OTHERS | 0 | Other scenarios.|
| STARTUP | 1 | Privacy statement displayed in the startup wizard.|
| CORE_LOCATION | 2 | Privacy statement displayed when enabling the location service.|
Z
zengyawen 已提交
1462 1463


S
shawn_he 已提交
1464
## LocationCommand<sup>(deprecated) </sup>
Z
zengyawen 已提交
1465 1466 1467

Defines an extended command.

S
shawn_he 已提交
1468 1469 1470 1471 1472
> **NOTE**
> This API is supported since API version 8.
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.LocationCommand](js-apis-geoLocationManager.md#locationcommand).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1473 1474 1475

**System capability**: SystemCapability.Location.Location.Core

S
shawn_he 已提交
1476 1477 1478 1479
| Name| Type| Readable|Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| scenario | [LocationRequestScenario](#locationrequestscenario)  | Yes| Yes | Location scenario.|
| command | string | Yes| Yes | Extended command, in the string format.|
Z
zengyawen 已提交
1480 1481


S
shawn_he 已提交
1482
## Location<sup>(deprecated) </sup>
Z
zengyawen 已提交
1483 1484 1485

Defines a location.

S
shawn_he 已提交
1486 1487 1488 1489
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.Location](js-apis-geoLocationManager.md#location).

**Required permissions**: ohos.permission.LOCATION
S
shawn_he 已提交
1490 1491 1492

**System capability**: SystemCapability.Location.Location.Core

S
shawn_he 已提交
1493 1494 1495
| Name| Type| Readable|Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| latitude<sup>7+</sup> | number | Yes| No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.|
S
shawn_he 已提交
1496
| longitude<sup>7+</sup> | number | Yes| No| Longitude information. A positive value indicates east longitude, and a negative value indicates west longitude.|
S
shawn_he 已提交
1497 1498 1499 1500 1501 1502 1503 1504
| altitude<sup>7+</sup> | number | Yes| No| Location altitude, in meters.|
| accuracy<sup>7+</sup> | number | Yes| No| Location accuracy, in meters.|
| speed<sup>7+</sup> | number | Yes| No| Speed, in m/s.|
| timeStamp<sup>7+</sup> | number | Yes| No| Location timestamp in the UTC format.|
| direction<sup>7+</sup> | number | Yes| No| Direction information.|
| timeSinceBoot<sup>7+</sup> | number | Yes| No| Location timestamp since boot.|
| additions<sup>7+</sup> | Array&lt;string&gt; | Yes| No| Additional description.|
| additionSize<sup>7+</sup> | number | Yes| No| Number of additional descriptions.|