1# @ohos.geoLocationManager (Geolocation Manager) (System API)
2
3The **geoLocationManager** module provides location services such as Global Navigation Satellite System (GNSS)-based positioning, network positioning, geofencing, as well as geocoding and reverse geocoding.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.geoLocationManager (Geolocation Manager)](js-apis-geoLocationManager.md).
9> This module supports only the WGS-84 coordinate system.
10
11## Applying for Permissions
12
13Before 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.
14
15The system provides the following location permissions:
16- ohos.permission.LOCATION
17
18- ohos.permission.APPROXIMATELY_LOCATION
19
20- ohos.permission.LOCATION_IN_BACKGROUND
21
22If your application needs to access the device location information, it must first apply for required permissions. Specifically speaking:
23
24API versions earlier than 9: Apply for **ohos.permission.LOCATION**.
25
26API 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.
27
28| API Version| Location Permission| Permission Application Result| Location Accuracy|
29| -------- | -------- | -------- | -------- |
30| Earlier than 9| ohos.permission.LOCATION | Success| Location accurate to meters|
31| 9 and later| ohos.permission.LOCATION | Failure| No location obtained|
32| 9 and later| ohos.permission.APPROXIMATELY_LOCATION | Success| Location accurate to 5 kilometers|
33| 9 and later| ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION| Success| Location accurate to meters|
34
35To 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.
36
37A 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).
38
39For details about how to request for a continuous task, see [Continuous Task](../../task-management/continuous-task.md).
40
41You can declare the required permission in your application's configuration file. For details, see [Requesting User Authorization](../../security/AccessToken/request-user-authorization.md).
42
43
44## Modules to Import
45
46```ts
47import { geoLocationManager } from '@kit.LocationKit';
48```
49
50## GeoAddress
51
52Geocoding address information.
53
54**System capability**: SystemCapability.Location.Location.Geocoder
55
56| Name| Type| Read Only| Optional| Description|
57| -------- | -------- | -------- | -------- | -------- |
58| isFromMock | Boolean | No| Yes| **true**: The geographic address is obtained from the mock reverse geocoding function.<br>**false**: The geographic address is not obtained from the mock reverse geocoding function.<br>**System API**: This is a system API.|
59
60
61## Location
62
63Location information.
64
65**System capability**: SystemCapability.Location.Location.Core
66
67| Name| Type| Read Only| Optional| Description|
68| -------- | -------- | -------- | -------- | -------- |
69| isFromMock | Boolean | No| Yes| **true**: The location information is obtained from the mock location function.<br>**false**: The location information is not obtained from the location simulation function.<br>**System API**: This is a system API.|
70
71
72## ReverseGeocodingMockInfo
73
74Defines the configuration of the mock reverse geocoding function.
75
76**System capability**: SystemCapability.Location.Location.Core
77
78**System API**: This is a system API.
79
80| Name| Type| Read Only| Optional| Description|
81| -------- | -------- | -------- | -------- | -------- |
82| location |  [ReverseGeoCodeRequest](js-apis-geoLocationManager.md#reversegeocoderequest) | No| No| Latitude and longitude information.|
83| geoAddress |  [GeoAddress](#geoaddress) | No| No|Geographical name.|
84
85
86## LocationMockConfig
87
88Defines the configuration of the mock location function.
89
90**System capability**: SystemCapability.Location.Location.Core
91
92**System API**: This is a system API.
93
94| Name| Type| Read Only| Optional| Description|
95| -------- | -------- | -------- | -------- | -------- |
96| timeInterval | number | No| No| Time interval at which mock locations are reported, in seconds.|
97| locations | Array&lt;[Location](#location)&gt; | No| No| Array of mocked locations.|
98
99## LocatingRequiredDataConfig<sup>10+</sup>
100
101Defines the configuration for obtaining the required data of the location service.
102
103**System capability**: SystemCapability.Location.Location.Core
104
105**System API**: This is a system API.
106
107| Name| Type| Read Only| Optional| Description|
108| -------- | -------- | -------- | -------- | -------- |
109| type | [LocatingRequiredDataType](#locatingrequireddatatype10) | No| No| Type of the required data.|
110| needStartScan |  boolean | No| No| **true**: Scanning needs to be initiated.<br>**false**: Scanning does not need to be initiated.|
111| scanInterval |  number | No| Yes| Scanning interval, in milliseconds. The specified value must be greater than **0**. The default value is **10000**.|
112| scanTimeout |  number | No| Yes| Scanning timeout interval, in milliseconds. The value ranges from **0** to **600000**. The default value is **10000**.|
113
114
115## LocatingRequiredData<sup>10+</sup>
116
117Defines the required data of the location service, including the Wi-Fi or Bluetooth scanning result. After obtaining the data, an application can use the data for services such as network positioning.
118
119**System capability**: SystemCapability.Location.Location.Core
120
121**System API**: This is a system API.
122
123| Name| Type| Read Only| Optional| Description|
124| -------- | -------- | -------- | -------- | -------- |
125| wifiData | [WifiScanInfo](#wifiscaninfo10) | No| Yes| Wi-Fi scanning result.|
126| bluetoothData |  [BluetoothScanInfo](#bluetoothscaninfo10) | No| Yes| Bluetooth scanning result.|
127
128
129## WifiScanInfo<sup>10+</sup>
130
131Defines the Wi-Fi scanning information, including the SSID, BSSID, and RSSI of the scanned Wi-Fi hotspot.
132
133**System capability**: SystemCapability.Location.Location.Core
134
135**System API**: This is a system API.
136
137| Name| Type| Read Only| Optional| Description|
138| -------- | -------- | -------- | -------- | -------- |
139| ssid | string | No| No| Service set identifier (SSID) of a Wi-Fi hotspot, in UTF-8 format.|
140| bssid | string | No| No| Base station subsystem identifier (BSSID) of a Wi-Fi hotspot.|
141| rssi | number | No| No| Received signal strength indicator (RSSI) of a Wi-Fi hotspot, in dBm.|
142| frequency | number | No| No| Frequency of a Wi-Fi hotspot.|
143| timestamp | number | No| No| Scanning timestamp.|
144
145
146## BluetoothScanInfo<sup>10+</sup>
147
148Defines the Bluetooth scanning information.
149
150**System capability**: SystemCapability.Location.Location.Core
151
152**System API**: This is a system API.
153
154| Name| Type| Read Only| Optional| Description|
155| -------- | -------- | -------- | -------- | -------- |
156| deviceName | string | No| No| Name of a Bluetooth device.|
157| macAddress | string | No| No| MAC address of a Bluetooth device.|
158| rssi | number | No| No| Signal strength of a Bluetooth device, in dBm.|
159| timestamp | number | No| No| Scanning timestamp.|
160
161## LocationPrivacyType
162
163Defines the privacy statement type.
164
165**System capability**: SystemCapability.Location.Location.Core
166
167**System API**: This is a system API.
168
169| Name| Value| Description|
170| -------- | -------- | -------- |
171| OTHERS | 0 | Other scenarios. Reserved field.|
172| STARTUP | 1 | Privacy statement displayed in the startup wizard. The user needs to choose whether to agree with the statement.|
173| CORE_LOCATION | 2 | Privacy statement displayed when enabling the location service.|
174
175## LocatingRequiredDataType<sup>10+</sup>
176
177Defines the type of the required data of the location service.
178
179**System capability**: SystemCapability.Location.Location.Core
180
181**System API**: This is a system API.
182
183| Name| Value| Description|
184| -------- | -------- | -------- |
185| WIFI  | 1 | Wi-Fi scanning information.|
186| BLUETOOTH | 2 | Bluetooth scanning information.|
187
188
189## LocationIconStatus<sup>12+</sup>
190
191Defines the location icon status.
192
193**System capability**: SystemCapability.Location.Location.Core
194
195**System API**: This is a system API.
196
197| Name| Value| Description|
198| -------- | -------- | -------- |
199| LOCATING_NOT_STARTED  | 0 | No location services are available and the location icon does not need to be displayed.|
200| LOCATING_STARTED | 1 | Common location is in progress, and the common location icon needs to be displayed.|
201| HD_LOCATING_STARTED | 2 | High-precision location is in progress, and the high-precision location icon needs to be displayed.|
202
203
204## geoLocationManager.on('locatingRequiredDataChange')<sup>10+</sup>
205
206on(type: 'locatingRequiredDataChange', config: LocatingRequiredDataConfig, callback: Callback&lt;Array&lt;LocatingRequiredData&gt;&gt;): void;
207
208Subscribes to changes in the required data of the location service, including Wi-Fi and Bluetooth scanning information. An application can then determine whether to enable Wi-Fi and Bluetooth scanning based on the return result. This API uses an asynchronous callback to return the result.
209
210**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
211
212**System capability**: SystemCapability.Location.Location.Core
213
214**System API**: This is a system API.
215
216**Parameters**
217
218  | Name| Type| Mandatory| Description|
219  | -------- | -------- | -------- | -------- |
220  | type | string | Yes| Event type. The value **locatingRequiredDataChange** indicates a change in the required data of the location service.|
221  | config | [LocatingRequiredDataConfig](#locatingrequireddataconfig10) | Yes| Configuration for obtaining the required data of the location service.|
222  | callback | Callback&lt;Array&lt;[LocatingRequiredData](#locatingrequireddata10)&gt;&gt; | Yes| Callback used to return the data required by the location service.|
223
224**Error codes**
225
226For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
227
228| ID| Error Message|
229| -------- | ---------------------------------------- |
230|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
231|202 | Permission verification failed. A non-system application calls a system API. |
232|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
233|801 | Capability not supported. Failed to call ${geoLocationManager.on('locatingRequiredDataChange')} due to limited device capabilities.          |
234|3301800 | Failed to start WiFi or Bluetooth scanning.                            |
235
236**Example**
237
238  ```ts
239  import { geoLocationManager } from '@kit.LocationKit';
240  import { BusinessError } from '@kit.BasicServicesKit'
241  let callback = (code:Array<geoLocationManager.LocatingRequiredData>):void => {
242      console.log('locatingRequiredDataChange: ' + JSON.stringify(code));
243  }
244  let config:geoLocationManager.LocatingRequiredDataConfig = {'type': 1, 'needStartScan': true, 'scanInterval': 10000};
245  try {
246      geoLocationManager.on('locatingRequiredDataChange', config, callback);
247  } catch (err) {
248      console.error("errCode:" + JSON.stringify(err));
249  }
250  ```
251
252
253## geoLocationManager.off('locatingRequiredDataChange')<sup>10+</sup>
254
255off(type: 'locatingRequiredDataChange', callback?: Callback&lt;Array&lt;LocatingRequiredData&gt;&gt;): void;
256
257Unsubscribes from changes in the required data of the location service and stops Wi-Fi and Bluetooth scanning.
258
259**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
260
261**System capability**: SystemCapability.Location.Location.Core
262
263**System API**: This is a system API.
264
265**Parameters**
266
267  | Name| Type| Mandatory| Description|
268  | -------- | -------- | -------- | -------- |
269  | type | string | Yes| Event type. The value **locatingRequiredDataChange** indicates a change in the required data of the location service.|
270  | callback | Callback&lt;Array&lt;[LocatingRequiredData](#locatingrequireddata10)&gt;&gt; | 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.|
271
272**Error codes**
273
274For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
275
276| ID| Error Message|
277| -------- | ---------------------------------------- |
278|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
279|202 | Permission verification failed. A non-system application calls a system API. |
280|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
281|801 | Capability not supported. Failed to call ${geoLocationManager.off('locatingRequiredDataChange')} due to limited device capabilities.          |
282
283**Example**
284
285  ```ts
286  import { geoLocationManager } from '@kit.LocationKit';
287  import { BusinessError } from '@kit.BasicServicesKit'
288  let callback = (code:Array<geoLocationManager.LocatingRequiredData>):void => {
289      console.log('locatingRequiredDataChange: ' + JSON.stringify(code));
290  }
291  let config:geoLocationManager.LocatingRequiredDataConfig = {'type': 1, 'needStartScan': true, 'scanInterval': 10000};
292  try {
293      geoLocationManager.on('locatingRequiredDataChange', config, callback);
294      geoLocationManager.off('locatingRequiredDataChange', callback);
295  } catch (err) {
296      console.error("errCode:" + JSON.stringify(err));
297  }
298  ```
299
300## geoLocationManager.enableLocation
301
302enableLocation(callback: AsyncCallback&lt;void&gt;): void;
303
304Enables the location service. This API uses an asynchronous callback to return the result.
305
306**System API**: This is a system API.
307
308**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
309
310**System capability**: SystemCapability.Location.Location.Core
311
312**Parameters**
313
314  | Name| Type| Mandatory| Description|
315  | -------- | -------- | -------- | -------- |
316  | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the location service is successfully enabled, **err** is **undefined**. Otherwise, **err** is an error object.|
317
318**Error codes**
319
320For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
321
322| ID| Error Message|
323| -------- | ---------------------------------------- |
324|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
325|202 | Permission verification failed. A non-system application calls a system API. |
326|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
327|801 | Capability not supported. Failed to call ${geoLocationManager.enableLocation} due to limited device capabilities.          |
328|3301000 | The location service is unavailable.                                              |
329
330**Example**
331
332  ```ts
333  import { geoLocationManager } from '@kit.LocationKit';
334  import { BusinessError } from '@kit.BasicServicesKit'
335  try {
336      geoLocationManager.enableLocation((err) => {
337          if (err) {
338              console.error('enableLocation: err=' + JSON.stringify(err));
339          }
340      });
341  } catch (err) {
342      console.error("errCode:" + JSON.stringify(err));
343  }
344  ```
345
346
347## geoLocationManager.enableLocation
348
349enableLocation(): Promise&lt;void&gt;
350
351Enables the location service. This API uses a promise to return the result.
352
353**System API**: This is a system API.
354
355**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
356
357**System capability**: SystemCapability.Location.Location.Core
358
359**Return value**
360
361  | Type| Description|
362  | -------- | -------- |
363  | Promise&lt;void&gt; | Promise that returns no value.|
364
365**Error codes**
366
367For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
368
369| ID| Error Message|
370| -------- | ---------------------------------------- |
371|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
372|202 | Permission verification failed. A non-system application calls a system API. |
373|801 | Capability not supported. Failed to call ${geoLocationManager.enableLocation} due to limited device capabilities.          |
374|3301000 | The location service is unavailable.                                            |
375
376**Example**
377
378  ```ts
379  import { geoLocationManager } from '@kit.LocationKit';
380  import { BusinessError } from '@kit.BasicServicesKit'
381  try {
382      geoLocationManager.enableLocation().then(() => {
383          console.log('promise, enableLocation succeed');
384      })
385      .catch((error:BusinessError.BusinessError) => {
386          console.error('promise, enableLocation: error=' + JSON.stringify(error));
387      });
388  } catch (err) {
389      console.error("errCode:" + JSON.stringify(err));
390  }
391  ```
392
393## geoLocationManager.disableLocation
394
395disableLocation(): void;
396
397Disables the location service.
398
399**System API**: This is a system API.
400
401**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
402
403**System capability**: SystemCapability.Location.Location.Core
404
405**Error codes**
406
407For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
408
409| ID| Error Message|
410| -------- | ---------------------------------------- |
411|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
412|202 | Permission verification failed. A non-system application calls a system API. |
413|801 | Capability not supported. Failed to call ${geoLocationManager.disableLocation} due to limited device capabilities.          |
414|3301000 | The location service is unavailable.                                            |
415
416**Example**
417
418  ```ts
419  import { geoLocationManager } from '@kit.LocationKit';
420  try {
421      geoLocationManager.disableLocation();
422  } catch (err) {
423      console.error("errCode:" + JSON.stringify(err));
424  }
425  ```
426
427## geoLocationManager.enableLocationMock
428
429enableLocationMock(): void;
430
431Enables the mock location function.
432
433**System capability**: SystemCapability.Location.Location.Core
434
435**System API**: This is a system API.
436
437**Error codes**
438
439For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
440
441| ID| Error Message|
442| -------- | ---------------------------------------- |
443|202 | Permission verification failed. A non-system application calls a system API. |
444|801 | Capability not supported. Failed to call ${geoLocationManager.enableLocationMock} due to limited device capabilities.          |
445|3301000 | The location service is unavailable.                                            |
446|3301100 | The location switch is off.|
447
448**Example**
449
450  ```ts
451  import { geoLocationManager } from '@kit.LocationKit';
452  try {
453      geoLocationManager.enableLocationMock();
454  } catch (err) {
455      console.error("errCode:" + JSON.stringify(err));
456  }
457  ```
458
459
460## geoLocationManager.disableLocationMock
461
462disableLocationMock(): void;
463
464Disables the mock location function.
465
466**System capability**: SystemCapability.Location.Location.Core
467
468**System API**: This is a system API.
469
470**Error codes**
471
472For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
473
474| ID| Error Message|
475| -------- | ---------------------------------------- |
476|202 | Permission verification failed. A non-system application calls a system API. |
477|801 | Capability not supported. Failed to call ${geoLocationManager.disableLocationMock} due to limited device capabilities.          |
478|3301000 | The location service is unavailable.                                            |
479|3301100 | The location switch is off.|
480
481**Example**
482
483  ```ts
484  import { geoLocationManager } from '@kit.LocationKit';
485  try {
486      geoLocationManager.disableLocationMock();
487  } catch (err) {
488      console.error("errCode:" + JSON.stringify(err));
489  }
490  ```
491
492
493## geoLocationManager.setMockedLocations
494
495setMockedLocations(config: LocationMockConfig): void;
496
497Sets the mock location information. The mock locations will be reported at the interval specified in this API.
498
499This API can be invoked only after [geoLocationManager.enableLocationMock](#geolocationmanagerenablelocationmock) is called.
500
501**System capability**: SystemCapability.Location.Location.Core
502
503**System API**: This is a system API.
504
505**Parameters**
506
507  | Name| Type| Mandatory| Description|
508  | -------- | -------- | -------- | -------- |
509  | config |  [LocationMockConfig](#locationmockconfig) | Yes| Mock location information, including the interval for reporting the mock locations and the array of the mock locations.|
510
511**Error codes**
512
513For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
514
515| ID| Error Message|
516| -------- | ---------------------------------------- |
517|202 | Permission verification failed. A non-system application calls a system API. |
518|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
519|801 | Capability not supported. Failed to call ${geoLocationManager.setMockedLocations} due to limited device capabilities.          |
520|3301000 | The location service is unavailable.                                            |
521|3301100 | The location switch is off.|
522
523**Example**
524
525  ```ts
526  import { geoLocationManager } from '@kit.LocationKit';
527  let locations:Array<geoLocationManager.Location> = [
528      {"latitude": 30.12, "longitude": 120.11, "altitude": 123, "accuracy": 1, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 1000000000, "additionSize": 0, "isFromMock": true},
529      {"latitude": 31.13, "longitude": 121.11, "altitude": 123, "accuracy": 2, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 2000000000, "additionSize": 0, "isFromMock": true},
530      {"latitude": 32.14, "longitude": 122.11, "altitude": 123, "accuracy": 3, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 3000000000, "additionSize": 0, "isFromMock": true},
531      {"latitude": 33.15, "longitude": 123.11, "altitude": 123, "accuracy": 4, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 4000000000, "additionSize": 0, "isFromMock": true},
532      {"latitude": 34.16, "longitude": 124.11, "altitude": 123, "accuracy": 5, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 5000000000, "additionSize": 0, "isFromMock": true}
533  ];
534  let config:geoLocationManager.LocationMockConfig = {"timeInterval": 5, "locations": locations};
535  try {
536      geoLocationManager.enableLocationMock();
537      geoLocationManager.setMockedLocations(config);
538  } catch (err) {
539      console.error("errCode:" + JSON.stringify(err));
540  }
541  ```
542
543
544## geoLocationManager.enableReverseGeocodingMock
545
546enableReverseGeocodingMock(): void;
547
548Enables the mock reverse geocoding function.
549
550**System capability**: SystemCapability.Location.Location.Core
551
552**System API**: This is a system API.
553
554**Error codes**
555
556For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
557
558| ID| Error Message|
559| -------- | ---------------------------------------- |
560|202 | Permission verification failed. A non-system application calls a system API. |
561|801 | Capability not supported. Failed to call ${geoLocationManager.enableReverseGeocodingMock} due to limited device capabilities.          |
562|3301000 | The location service is unavailable.                                            |
563
564**Example**
565
566  ```ts
567  import { geoLocationManager } from '@kit.LocationKit';
568  try {
569      geoLocationManager.enableReverseGeocodingMock();
570  } catch (err) {
571      console.error("errCode:" + JSON.stringify(err));
572  }
573  ```
574
575
576## geoLocationManager.disableReverseGeocodingMock
577
578disableReverseGeocodingMock(): void;
579
580Disables the mock geocoding function.
581
582**System capability**: SystemCapability.Location.Location.Core
583
584**System API**: This is a system API.
585
586**Error codes**
587
588For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
589
590| ID| Error Message|
591| -------- | ---------------------------------------- |
592|202 | Permission verification failed. A non-system application calls a system API. |
593|801 | Capability not supported. Failed to call ${geoLocationManager.disableReverseGeocodingMock} due to limited device capabilities.          |
594|3301000 | The location service is unavailable.                                            |
595
596**Example**
597
598  ```ts
599  import { geoLocationManager } from '@kit.LocationKit';
600  try {
601      geoLocationManager.disableReverseGeocodingMock();
602  } catch (err) {
603      console.error("errCode:" + JSON.stringify(err));
604  }
605  ```
606
607
608## geoLocationManager.setReverseGeocodingMockInfo
609
610setReverseGeocodingMockInfo(mockInfos: Array&lt;ReverseGeocodingMockInfo&gt;): void;
611
612Sets information of the mock reverse geocoding function, including the mapping between a location and geographical name. If the location is contained in the configurations during reverse geocoding query, the corresponding geographical name will be returned.
613
614This API can be invoked only after [geoLocationManager.enableReverseGeocodingMock](#geolocationmanagerenablereversegeocodingmock) is called.
615
616**System capability**: SystemCapability.Location.Location.Core
617
618**System API**: This is a system API.
619
620**Parameters**
621
622  | Name| Type| Mandatory| Description|
623  | -------- | -------- | -------- | -------- |
624  | mockInfos | Array&lt;[ReverseGeocodingMockInfo](#reversegeocodingmockinfo)&gt; | Yes| Array of information of the mock reverse geocoding function, including a location and a geographical name.|
625
626**Error codes**
627
628For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
629
630| ID| Error Message|
631| -------- | ---------------------------------------- |
632|202 | Permission verification failed. A non-system application calls a system API. |
633|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
634|801 | Capability not supported. Failed to call ${geoLocationManager.setReverseGeocodingMockInfo} due to limited device capabilities.          |
635|3301000 | The location service is unavailable.                                            |
636
637**Example**
638
639  ```ts
640  import { geoLocationManager } from '@kit.LocationKit';
641  let mockInfos:Array<geoLocationManager.ReverseGeocodingMockInfo> = [
642      {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "isFromMock": true}},
643      {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "isFromMock": true}},
644      {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "isFromMock": true}},
645      {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "isFromMock": true}},
646      {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "isFromMock": true}},
647  ];
648  try {
649      geoLocationManager.enableReverseGeocodingMock();
650      geoLocationManager.setReverseGeocodingMockInfo(mockInfos);
651  } catch (err) {
652      console.error("errCode:" + JSON.stringify(err));
653  }
654  ```
655
656
657## geoLocationManager.isLocationPrivacyConfirmed
658
659isLocationPrivacyConfirmed(type: LocationPrivacyType): boolean;
660
661Checks whether a user agrees with the privacy statement of the location service. This API can only be called by system applications.
662
663**System API**: This is a system API.
664
665**System capability**: SystemCapability.Location.Location.Core
666
667**Parameters**
668
669  | Name| Type| Mandatory| Description|
670  | -------- | -------- | -------- | -------- |
671  | type |  [LocationPrivacyType](#locationprivacytype)| Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when the location service is enabled.|
672
673**Return value**
674
675  | Type| Description|
676  | -------- | -------- |
677  | boolean | **true**: The user agrees to the privacy statement of the location service.<br>**false**: The user does not agree to the privacy statement of the location service.|
678
679**Error codes**
680
681For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
682
683| ID| Error Message|
684| -------- | ---------------------------------------- |
685|202 | Permission verification failed. A non-system application calls a system API. |
686|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
687|801 | Capability not supported. Failed to call ${geoLocationManager.isLocationPrivacyConfirmed} due to limited device capabilities.          |
688|3301000 | The location service is unavailable.                                            |
689
690**Example**
691
692  ```ts
693  import { geoLocationManager } from '@kit.LocationKit';
694  try {
695      let isConfirmed = geoLocationManager.isLocationPrivacyConfirmed(1);
696  } catch (err) {
697      console.error("errCode:" + JSON.stringify(err));
698  }
699  ```
700
701
702## geoLocationManager.setLocationPrivacyConfirmStatus
703
704setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): void;
705
706Sets the user confirmation status for the privacy statement of the location service. This API can only be called by system applications.
707
708**System API**: This is a system API.
709
710**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
711
712**System capability**: SystemCapability.Location.Location.Core
713
714**Parameters**
715
716  | Name| Type| Mandatory| Description|
717  | -------- | -------- | -------- | -------- |
718  | type | [LocationPrivacyType](#locationprivacytype) | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when the location service is enabled.|
719  | isConfirmed | boolean | Yes| **true**: The user agrees to the privacy statement of the location service.<br>**false**: The user does not agree to the privacy statement of the location service.|
720
721**Error codes**
722
723For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
724
725| ID| Error Message|
726| -------- | ---------------------------------------- |
727|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
728|202 | Permission verification failed. A non-system application calls a system API. |
729|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
730|801 | Capability not supported. Failed to call ${geoLocationManager.setLocationPrivacyConfirmStatus} due to limited device capabilities.          |
731|3301000 | The location service is unavailable.                                            |
732
733**Example**
734
735  ```ts
736  import { geoLocationManager } from '@kit.LocationKit';
737  try {
738      geoLocationManager.setLocationPrivacyConfirmStatus(1, true);
739  } catch (err) {
740      console.error("errCode:" + JSON.stringify(err));
741  }
742  ```
743
744
745## geoLocationManager.getLocatingRequiredData<sup>10+</sup>
746
747getLocatingRequiredData(config: LocatingRequiredDataConfig): Promise&lt;Array&lt;LocatingRequiredData&gt;&gt;;
748
749Obtains the required data of the location service. This API uses a promise to return the result.
750
751**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
752
753**System capability**: SystemCapability.Location.Location.Core
754
755**System API**: This is a system API.
756
757**Parameters**
758
759  | Name| Type| Mandatory| Description|
760  | -------- | -------- | -------- | -------- |
761  | config | [LocatingRequiredDataConfig](#locatingrequireddataconfig10) | Yes| Configuration for obtaining the required data of the location service.|
762
763**Return value**
764
765  | Type| Description|
766  | -------- | -------- |
767  | Promise&lt;Array&lt;[LocatingRequiredData](#locatingrequireddata10)&gt;&gt; | Promise used to return the required data for the location service, such as the Wi-Fi and Bluetooth scanning information.|
768
769**Error codes**
770
771For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
772
773| ID| Error Message|
774| -------- | ---------------------------------------- |
775|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
776|202 | Permission verification failed. A non-system application calls a system API. |
777|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
778|801 | Capability not supported. Failed to call ${geoLocationManager.getLocatingRequiredData} due to limited device capabilities.          |
779|3301800  | Failed to start WiFi or Bluetooth scanning.                    |
780
781**Example**
782
783  ```ts
784  import { geoLocationManager } from '@kit.LocationKit';
785  import { BusinessError } from '@kit.BasicServicesKit'
786  let config:geoLocationManager.LocatingRequiredDataConfig = {'type': 1, 'needStartScan': true, 'scanInterval': 10000};
787  try {
788      geoLocationManager.getLocatingRequiredData(config).then((result) => {
789          console.log('getLocatingRequiredData return: ' + JSON.stringify(result));
790      })  
791      .catch((error:BusinessError.BusinessError) => {
792          console.error('promise, getLocatingRequiredData: error=' + JSON.stringify(error));
793      });
794  } catch (err) {
795      console.error("errCode:" + JSON.stringify(err));
796  }
797  ```
798
799
800## geoLocationManager.on('locationIconStatusChange')<sup>12+</sup>
801
802on(type: 'locationIconStatusChange', callback: Callback&lt;LocationIconStatus&gt;): void;
803
804Subscribes to status changes of the location icon. This API uses an asynchronous callback to return the result.
805
806**System capability**: SystemCapability.Location.Location.Core
807
808**System API**: This is a system API.
809
810**Parameters**
811
812  | Name| Type| Mandatory| Description|
813  | -------- | -------- | -------- | -------- |
814  | type | string | Yes| Event type. Event type. The value **locationIconStatusChange** indicates status changes of the location icon.|
815  | callback | Callback&lt;[LocationIconStatus](#locationiconstatus12)&gt; | Yes| Callback used to return the location icon status.|
816
817**Error codes**
818
819For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
820
821| ID| Error Message|
822| -------- | ---------------------------------------- |
823|202 | Permission verification failed. A non-system application calls a system API. |
824|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
825|801 | Capability not supported. Failed to call ${geoLocationManager.on('locationIconStatusChange')} due to limited device capabilities.          |
826|3301000 | The location service is unavailable.                        |
827
828**Example**
829
830  ```ts
831  import { geoLocationManager } from '@kit.LocationKit';
832  let callback = (code: geoLocationManager.LocationIconStatus):void => {
833      console.log('LocationIconStatus: ' + JSON.stringify(code));
834  }
835  try {
836      geoLocationManager.on('locationIconStatusChange', callback);
837  } catch (err) {
838      console.error("errCode:" + JSON.stringify(err));
839  }
840  ```
841
842
843## geoLocationManager.off('locationIconStatusChange')<sup>12+</sup>
844
845off(type: 'locationIconStatusChange', callback?: Callback&lt;LocationIconStatus&gt;): void;
846
847Unsubscribes from status changes of the location icon.
848
849**System capability**: SystemCapability.Location.Location.Core
850
851**System API**: This is a system API.
852
853**Parameters**
854
855  | Name| Type| Mandatory| Description|
856  | -------- | -------- | -------- | -------- |
857  | type | string | Yes| Event type. Event type. The value **locationIconStatusChange** indicates status changes of the location icon.|
858  | callback | Callback&lt;[LocationIconStatus](#locationiconstatus12)&gt;  | 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.|
859
860**Error codes**
861
862For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
863
864| ID| Error Message|
865| -------- | ---------------------------------------- |
866|202 | Permission verification failed. A non-system application calls a system API. |
867|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
868|801 | Capability not supported. Failed to call ${geoLocationManager.off('locationIconStatusChange')} due to limited device capabilities.          |
869|3301000 | The location service is unavailable.        |
870
871**Example**
872
873  ```ts
874  import { geoLocationManager } from '@kit.LocationKit';
875  let callback = (code: geoLocationManager.LocationIconStatus):void => {
876      console.log('LocationIconStatus: ' + JSON.stringify(code));
877  }
878  try {
879      geoLocationManager.on('locationIconStatusChange', callback);
880	  geoLocationManager.off('locationIconStatusChange', callback);
881  } catch (err) {
882      console.error("errCode:" + JSON.stringify(err));
883  }
884  ```
885
886
887## geoLocationManager.getLocationIconStatus<sup>12+</sup>
888
889getLocationIconStatus(): LocationIconStatus;
890
891Obtains the current location icon status.
892
893**System capability**: SystemCapability.Location.Location.Core
894
895**System API**: This is a system API.
896
897**Return value**
898
899  | Type| Description|
900  | -------- | -------- |
901  | [LocationIconStatus](#locationiconstatus12) | Location icon status.|
902
903**Error codes**
904
905For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
906
907| ID| Error Message|
908| -------- | ---------------------------------------- |
909|202 | Permission verification failed. A non-system application calls a system API. |
910|801 | Capability not supported. Failed to call ${geoLocationManager.getLocationIconStatus} due to limited device capabilities.          |
911|3301000  | The location service is unavailable.                  |
912
913**Example**
914
915  ```ts
916  import { geoLocationManager } from '@kit.LocationKit';
917  try {
918      let iconStatus = geoLocationManager.getLocationIconStatus();
919  } catch (err) {
920      console.error("errCode:" + JSON.stringify(err));
921  }
922  ```
923