1# @ohos.geoLocationManager (Geolocation Manager)
2
3The **geoLocationManager** module provides basic location services such as Global Navigation Satellite System (GNSS)-based positioning, network positioning (for example, base station positioning or WLAN/Bluetooth positioning), geofencing, as well as geocoding and reverse geocoding.
4
5To use location services, turn on the Location switch on your device. If the switch is turned off while exception capture is disabled, the application may run into an error.
6
7> **NOTE**
8>
9> 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.
10> This module supports only the WGS-84 coordinate system.
11
12## Applying for Permissions
13
14For details, see [Applying for Location Permissions](../../device/location/location-guidelines.md#applying-for-location-permissions).
15
16
17## Modules to Import
18
19```ts
20import { geoLocationManager } from '@kit.LocationKit';
21```
22
23
24## ReverseGeoCodeRequest
25
26Defines a reverse geocoding request.
27
28**System capability**: SystemCapability.Location.Location.Geocoder
29
30| Name| Type| Read Only| Optional| Description|
31| -------- | -------- | -------- | -------- | -------- |
32| locale | string | No| Yes| Language used for the location description. **zh** indicates Chinese, and **en** indicates English. The default language is obtained from **Language and region** in **Settings**.|
33| country<sup>12+</sup> | string | No| Yes| Country information. The country code complies with the ISO 3166-1 alpha-2 standard. **CN** indicates China. The default language is obtained from **Language and region** in **Settings**.|
34| latitude | number | No| No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude. The value ranges from **-90** to **90**. Only the WGS84 coordinate system is supported.|
35| longitude | number | No| No| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude . The value ranges from **-180** to **180**. Only the WGS84 coordinate system is supported.|
36| maxItems | number | No| Yes| Maximum number of location records to be returned. The specified value must be greater than or equal to **0**. A value smaller than **10** is recommended. The default value is **1**.|
37
38
39## GeoCodeRequest
40
41Defines a reverse geocoding request.
42
43**System capability**: SystemCapability.Location.Location.Geocoder
44
45| Name| Type| Read Only| Optional| Description|
46| -------- | -------- | -------- | -------- | -------- |
47| locale | string | No| Yes| Language used for the location description. **zh** indicates Chinese, and **en** indicates English. The default language is obtained from **Language and region** in **Settings**.|
48| country<sup>12+</sup> | string | No| Yes| Country information. The country code complies with the ISO 3166-1 alpha-2 standard. **CN** indicates China. The default language is obtained from **Language and region** in **Settings**.|
49| description | string | No| No| Location description, for example, **No. xx, xx Road, Pudong New District, Shanghai**.|
50| maxItems | number | No| Yes| Maximum number of location records to be returned. The specified value must be greater than or equal to **0**. A value smaller than **10** is recommended. The default value is **1**.|
51| minLatitude | number | No| Yes| Minimum latitude. This parameter is used with **minLongitude**, **maxLatitude**, and **maxLongitude** to specify the latitude and longitude ranges. The value ranges from **-90** to **90**. Only the WGS84 coordinate system is supported. The following three parameters are mandatory is this parameter is specified.|
52| minLongitude | number | No| Yes| Minimum longitude. The value ranges from **-180** to **180**. Only the WGS84 coordinate system is supported.|
53| maxLatitude | number | No| Yes| Maximum latitude. The value ranges from **-90** to **90**. Only the WGS84 coordinate system is supported.|
54| maxLongitude | number | No| Yes| Maximum longitude. The value ranges from **-180** to **180**. Only the WGS84 coordinate system is supported.|
55
56
57## GeoAddress
58
59Geocoding address information.
60
61**System capability**: SystemCapability.Location.Location.Geocoder
62
63| Name| Type| Read Only| Optional| Description|
64| -------- | -------- | -------- | -------- | -------- |
65| latitude | number | No| Yes | Latitude information. A positive value indicates a north latitude, and a negative value indicates a south latitude. The value ranges from **-90** to **90**. Only the WGS84 coordinate system is supported.|
66| longitude | number | No| Yes | Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude . The value ranges from **-180** to **180**. Only the WGS84 coordinate system is supported.|
67| locale | string | No| Yes | Language used for the location description. **zh** indicates Chinese, and **en** indicates English.|
68| placeName | string | No| Yes | Address information.|
69| countryCode | string | No| Yes | Country code.|
70| countryName | string | No| Yes| Country name.|
71| administrativeArea | string | No| Yes| Level-1 administrative region, which is generally is a province or state.|
72| subAdministrativeArea | string | No| Yes| Level-2 administrative region, which is generally is a city.|
73| locality | string | No| Yes| Locality information, which is usually a city.|
74| subLocality | string | No| Yes| Sub-locality information, which is usually a district or county.|
75| roadName | string | No| Yes| Road name.|
76| subRoadName | string | No| Yes| Auxiliary road information.|
77| premises | string | No| Yes| House information.|
78| postalCode | string | No| Yes| Postal code.|
79| phoneNumber | string | No| Yes| Phone number.|
80| addressUrl | string | No| Yes| Website URL.|
81| descriptions | Array&lt;string&gt; | No| Yes| Additional description. It contains **cityCode** (the array subscript is **0**) and **adminCode** (the array subscript is **1**), for example, **["025","320114001"]**.|
82| descriptionsSize | number | No| Yes| Total number of additional descriptions. The specified value must be greater than or equal to **0**. A value smaller than **10** is recommended.|
83
84
85## LocationRequest
86
87Defines a location request.
88
89**Atomic service API**: This API can be used in atomic services since API version 11.
90
91**System capability**: SystemCapability.Location.Location.Core
92
93| Name| Type| Read Only| Optional| Description|
94| -------- | -------- | -------- | -------- | -------- |
95| priority | [LocationRequestPriority](#locationrequestpriority) | No| Yes| Priority of the location request. This parameter is effective only when **scenario** is set to **UNSET**. If this parameter and **scenario** are set to **UNSET**, the attempt to initiate a location request will fail. For details about the value range, see [LocationRequestPriority](#locationrequestpriority).|
96| scenario | [LocationRequestScenario](#locationrequestscenario) | No| Yes| Scenario of the location request. The **priority** parameter is effective only when this parameter is set to **UNSET**. If this parameter and **priority** are set to **UNSET**, the attempt to initiate a location request will fail. For details about the value range, see [LocationRequestScenario](#locationrequestscenario).|
97| timeInterval | number | No| Yes|  Time interval at which location information is reported, in seconds.<br>The value is greater than or equal to 0.<br>The default value is the minimum interval allowed in the corresponding positioning mode.<br>The default value is 1s for GNSS positioning and 20s for network positioning.<br>If the value is less than the minimum interval, the minimum interval takes effect.<br>If the value is set to **0**, location information is directly reported without checking of the time interval.|
98| distanceInterval | number | No| Yes| Distance interval at which location information is reported, in meters. The specified value must be greater than or equal to **0**. The default value is **0**. If this parameter is set to **0**, there is no limitation on the location reporting distance.|
99| maxAccuracy | number | No| Yes|  Location accuracy requested by the application, in meters. This parameter is valid only when the precise location function is enabled (both the **ohos.permission.APPROXIMATELY\_LOCATION** and **ohos.permission.LOCATION** permissions are granted). It is invalid when the approximate location function is enabled (only the **ohos.permission.APPROXIMATELY\_LOCATION** permission is enabled).<br>When this parameter is effective, the system compares the [location](#location) information reported by the GNSS or network location service with the location information requested by the application. If the accuracy in the reported [location](#location) information is less than or equal to **maxAccuracy**, the system sends the reported location information to the application. Otherwise, the system discards the location information.<br>The value must be greater than or equal to **0**. The default value is **0**, indicating no limitation on the location accuracy.<br>If **scenario** is set to **NAVIGATION**, **TRAJECTORY_TRACKING**, or **CAR_HAILING** or **priority** is set to **ACCURACY**, you are advised to set **maxAccuracy** to a value greater than **10**.<br>If scenario is set to **DAILY_LIFE_SERVICE** or **NO_POWER** or **priority** is set to **LOW_POWER** or **FIRST_FIX**, you are advised to set **maxAccuracy** to a value greater than **100**.<br>|
100
101
102## CurrentLocationRequest
103
104Defines a location request.
105
106**Atomic service API**: This API can be used in atomic services since API version 11.
107
108**System capability**: SystemCapability.Location.Location.Core
109
110| Name| Type| Read Only| Optional| Description|
111| -------- | -------- | -------- | -------- | -------- |
112| priority | [LocationRequestPriority](#locationrequestpriority) | No| Yes| Priority of the location request. This parameter is effective only when **scenario** is set to **UNSET**. If this parameter and **scenario** are set to **UNSET**, the attempt to initiate a location request will fail. For details about the value range, see [LocationRequestPriority](#locationrequestpriority).|
113| scenario | [LocationRequestScenario](#locationrequestscenario) | No| Yes| Scenario of the location request. The **priority** parameter is effective only when this parameter is set to **UNSET**. If this parameter and **priority** are set to **UNSET**, the attempt to initiate a location request will fail. For details about the value range, see [LocationRequestScenario](#locationrequestscenario).|
114| maxAccuracy | number | No| Yes|  Location accuracy requested by the application, in meters. This parameter is valid only when the precise location function is enabled (both the **ohos.permission.APPROXIMATELY\_LOCATION** and **ohos.permission.LOCATION** permissions are granted). It is invalid when the approximate location function is enabled (only the **ohos.permission.APPROXIMATELY\_LOCATION** permission is enabled).<br>When this parameter is effective, the system compares the [location](#location) information reported by the GNSS or network location service with the location information requested by the application. If the accuracy in the reported [location](#location) information is less than or equal to **maxAccuracy**, the system sends the reported location information to the application. Otherwise, the system discards the location information.<br>The value must be greater than or equal to **0**. The default value is **0**, indicating no limitation on the location accuracy.<br>If **scenario** is set to **NAVIGATION**, **TRAJECTORY_TRACKING**, or **CAR_HAILING** or **priority** is set to **ACCURACY**, you are advised to set **maxAccuracy** to a value greater than **10**.<br>If scenario is set to **DAILY_LIFE_SERVICE** or **NO_POWER** or **priority** is set to **LOW_POWER** or **FIRST_FIX**, you are advised to set **maxAccuracy** to a value greater than **100**.|
115| timeoutMs | number | No| Yes| Timeout duration, in milliseconds. The minimum value is **1000**. The specified value must be greater than or equal to **1000**.|
116
117
118## ContinuousLocationRequest<sup>12+</sup>
119
120Defines a continuous location request.
121
122**Atomic service API**: This API can be used in atomic services since API version 12.
123
124**System capability**: SystemCapability.Location.Location.Core
125
126| Name| Type| Read Only| Optional| Description|
127| -------- | -------- | -------- | -------- | -------- |
128| interval | number | No| No| Time interval at which location information is reported, in seconds. The specified value must be greater than or equal to **0**. The default value is **1**. If this parameter is set to **0**, there is no limitation on the location reporting interval.|
129| locationScenario | [UserActivityScenario](#useractivityscenario12) &#124; [PowerConsumptionScenario](#powerconsumptionscenario12) | No| No| Location scenario. For details, see [UserActivityScenario](#useractivityscenario12) and [PowerConsumptionScenario](#powerconsumptionscenario12).|
130
131
132## SingleLocationRequest<sup>12+</sup>
133
134Defines a single location request.
135
136**Atomic service API**: This API can be used in atomic services since API version 12.
137
138**System capability**: SystemCapability.Location.Location.Core
139
140| Name| Type| Read Only| Optional| Description|
141| -------- | -------- | -------- | -------- | -------- |
142| locatingPriority | [LocatingPriority](#locatingpriority12) | No| No| Priority of the location request. For details, see [LocatingPriority](#locatingpriority12).|
143| locatingTimeoutMs | number | No| No| Timeout duration, in milliseconds. The minimum value is **1000**. The specified value must be greater than or equal to **1000**.|
144
145
146## SatelliteStatusInfo
147
148Defines the satellite status information.
149
150**System capability**: SystemCapability.Location.Location.Gnss
151
152| Name| Type| Read Only| Optional| Description|
153| -------- | -------- | -------- | -------- | -------- |
154| satellitesNumber | number | No| No| Number of satellites. The specified value must be greater than or equal to **0**.|
155| satelliteIds | Array&lt;number&gt; | No| No| Array of satellite IDs. The specified value must be greater than or equal to **0**.|
156| carrierToNoiseDensitys | Array&lt;number&gt; | No| No| Carrier-to-noise density ratio, that is, **cn0**. The specified value must be greater than **0**.|
157| altitudes | Array&lt;number&gt; | No| No| Satellite altitude angle information. The value ranges from **-90** to **90**, in degrees.|
158| azimuths | Array&lt;number&gt; | No| No| Azimuth information. The value ranges from **0** to **360**, in degrees.|
159| carrierFrequencies | Array&lt;number&gt; | No| No| Carrier frequency, in Hz. The specified value must be greater than or equal to **0**.|
160| satelliteConstellation<sup>12+</sup> | Array&lt;[SatelliteConstellationCategory](#satelliteconstellationcategory12)&gt; | No| Yes| Satellite constellation type.|
161| satelliteAdditionalInfo<sup>12+</sup> | Array&lt;number&gt; | No| Yes| Additional satellite information.<br>Each bit has a different meaning. For details, see [SatelliteAdditionalInfo](#satelliteadditionalinfo12).|
162
163
164## CachedGnssLocationsRequest
165
166Defines a request for reporting cached GNSS locations.
167
168**System capability**: SystemCapability.Location.Location.Gnss
169
170| Name| Type| Read Only| Optional| Description|
171| -------- | -------- | -------- | -------- | -------- |
172| reportingPeriodSec | number | No| No| Interval for reporting the cached GNSS locations, in milliseconds. The specified value must be greater than **0**.|
173| wakeUpCacheQueueFull | boolean | No| No | **true**: reports the cached GNSS locations to the application when the cache queue is full.<br>**false**: discards the cached GNSS locations when the cache queue is full.|
174
175
176## Geofence
177
178Defines a GNSS geofence. Currently, only circular geofences are supported.
179
180**System capability**: SystemCapability.Location.Location.Geofence
181
182| Name| Type| Read Only| Optional| Description|
183| -------- | -------- | -------- | -------- | -------- |
184| latitude | number | No| No|Latitude information. The value ranges from **-90** to **90**.|
185| longitude | number | No|No| Longitude information. The value ranges from **-180** to **180**.|
186| coordinateSystemType<sup>12+</sup> | [CoordinateSystemType](#coordinatesystemtype12) | No|Yes| Coordinate system of the circle center of a geofence.<br>The application needs to call [getGeofenceSupportedCoordTypes](#geolocationmanagergetgeofencesupportedcoordtypes12) to query the supported coordinate systems and then pass in the correct coordinates of the circle center.|
187| radius | number | No|No| Radius of a circular geofence, in meters. The specified value must be greater than **0**.|
188| expiration | number | No|No| Expiration period of a geofence, in milliseconds. The specified value must be greater than **0**.|
189
190
191## GeofenceRequest
192
193Defines a geofence request.
194
195**System capability**: SystemCapability.Location.Location.Geofence
196
197| Name| Type| Read Only| Optional| Description|
198| -------- | -------- | -------- | -------- | -------- |
199| scenario | [LocationRequestScenario](#locationrequestscenario) | No| No |  Location scenario.|
200| geofence |  [Geofence](#geofence)| No| No |  Geofence information.|
201
202
203## LocationCommand
204
205Defines a location command.
206
207**System capability**: SystemCapability.Location.Location.Core
208
209| Name| Type| Read Only| Optional| Description|
210| -------- | -------- | -------- | -------- | -------- |
211| scenario | [LocationRequestScenario](#locationrequestscenario)  | No| No | Location scenario.|
212| command | string | No| No | Extended command, in the string format.|
213
214
215## Location
216
217Location information.
218
219**System capability**: SystemCapability.Location.Location.Core
220
221| Name| Type| Read Only| Optional| Description|
222| -------- | -------- | -------- | -------- | -------- |
223| latitude | number| No| No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude. The value ranges from **-90** to **90**. Only the WGS84 coordinate system is supported.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
224| longitude | number| No| No| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude . The value ranges from **-180** to **180**. Only the WGS84 coordinate system is supported.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
225| altitude | number | No| No| Location altitude, in meters.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
226| accuracy | number | No| No| Location accuracy, in meters.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
227| speed | number | No| No|Speed, in m/s.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
228| timeStamp | number | No| No| Location timestamp in the UTC format.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
229| direction | number | No| No| Direction information. The value ranges from **0** to **360**, in degrees.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
230| timeSinceBoot | number | No| No| Location timestamp since boot.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
231| additions | Array&lt;string&gt;| No| Yes| Additional description.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
232| additionSize | number| No| Yes| Number of additional descriptions. The specified value must be greater than or equal to **0**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
233| additionsMap<sup>12+</sup> | Map&lt;string, string&gt;| No| Yes| Additional description. The content and sequence are the same as those of **additions**.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
234| altitudeAccuracy<sup>12+</sup> |number | No| Yes| Height accuracy, in meters.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
235| speedAccuracy<sup>12+</sup> | number| No| Yes| Speed accuracy, in meters per second.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
236| directionAccuracy<sup>12+</sup> | number| No| Yes| Direction accuracy. The value ranges from **0** to **360**, in degrees.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
237| uncertaintyOfTimeSinceBoot<sup>12+</sup> | number| No| Yes| Uncertainty of the location timestamp.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
238| sourceType<sup>12+</sup> | [LocationSourceType](#locationsourcetype12) | No| Yes| Source of the location result.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
239
240
241## GeofenceTransition<sup>12+</sup>
242
243Defines a geofence transition event.
244
245**System capability**: SystemCapability.Location.Location.Geofence
246
247| Name| Type| Read Only| Optional| Description|
248| -------- | -------- | -------- | -------- | -------- |
249| geofenceId | number| No| No| Geofence ID.|
250| transitionEvent | [GeofenceTransitionEvent](#geofencetransitionevent12) | No| No| Geofence transition event.|
251
252
253## GnssGeofenceRequest<sup>12+</sup>
254
255Defines a GNSS geofence request.
256
257**System capability**: SystemCapability.Location.Location.Geofence
258
259| Name| Type| Read Only| Optional| Description|
260| -------- | -------- | -------- | -------- | -------- |
261| geofence | [Geofence](#geofence) | No| No| Geofence information, including the coordinates and radius of the circle center.|
262| monitorTransitionEvents | Array&lt;[GeofenceTransitionEvent](#geofencetransitionevent12)&gt; | No| No| List of geofence transition events.|
263| notifications | Array&lt;[NotificationRequest](../apis-notification-kit/js-apis-notification.md#notificationrequest)&gt; | No| Yes| List of notifications for geofence transition events.<br>The sequence of **monitorTransitionEvents** must correspond to that of **notifications**. For example, if **monitorTransitionEvents[0]** is **[GeofenceTransitionEvent](#geofencetransitionevent12).GEOFENCE_TRANSITION_EVENT_ENTER**, **notifications[0]** must be set to the notification that needs to be displayed when a user enters the geofence.|
264| geofenceTransitionCallback | AsyncCallback&lt;[GeofenceTransition](#geofencetransition12)&gt; | No| No| Callback used to receive geofence transition events.|
265
266
267## CountryCode
268
269Defines the country code information.
270
271**System capability**: SystemCapability.Location.Location.Core
272
273| Name| Type| Read Only| Optional| Description|
274| -------- | -------- | -------- | -------- | -------- |
275| country | string | No| No| Country code.|
276| type |  [CountryCodeType](#countrycodetype) | No| No| Country code source.|
277
278
279## LocationRequestPriority
280
281Sets the priority of a location request.
282
283**Atomic service API**: This API can be used in atomic services since API version 11.
284
285**System capability**: SystemCapability.Location.Location.Core
286
287| Name| Value| Description|
288| -------- | -------- | -------- |
289| UNSET | 0x200 | Priority unspecified.<br>If this option is used, [LocationRequestPriority](#locationrequestpriority) is invalid.|
290| ACCURACY | 0x201 | Location accuracy.<br>The location accuracy priority mainly uses the GNSS positioning technology. The system uses the network positioning technology as an alternative to provide the location service for your application until the GNSS can provide stable location results. During the continuous location process, the network positioning technology is used if the GNSS location result cannot be obtained within 30 seconds. This policy can lead to significant hardware resource consumption and power consumption.|
291| LOW_POWER | 0x202 | Power efficiency.<br>This policy uses only the network positioning technology to obtain device location in both indoor and outdoor scenarios. The location accuracy depends on the distribution of surrounding base stations, visible WLANs, and Bluetooth devices and therefore may fluctuate greatly. This policy is recommended and can reduce power consumption if a high location accuracy is not required.|
292| FIRST_FIX | 0x203 | Fast location preferred. Use this option if you want to obtain a location as fast as possible.<br>This policy uses the GNSS positioning and network positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios. When all positioning technologies provide a location result, the system provides the most accurate location result for your application. It can lead to significant hardware resource consumption and power consumption.|
293
294
295## LocationRequestScenario
296
297Defines the location scenario in a location request.
298
299**Atomic service API**: This API can be used in atomic services since API version 11.
300
301**System capability**: SystemCapability.Location.Location.Core
302
303> **NOTE**
304>
305> If a single location or continuous location is initiated in the NAVIGATION, TRAJECTORY_TRACKING, or CAR_HAILING scenario, the system uses the network positioning technology as an alternative to provide the location service for your application until the GNSS can provide stable location results. During the continuous location process, the network positioning technology is used if the GNSS location result cannot be obtained within 30 seconds.
306
307| Name| Value| Description|
308| -------- | -------- | -------- |
309| UNSET | 0x300 | Scenario unspecified.<br>If this option is used, [LocationRequestScenario](#locationrequestscenario) is invalid.|
310| NAVIGATION | 0x301 | Navigation.<br>This option is applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking.<br>This option mainly uses the GNSS positioning technology and therefore the power consumption is relatively high.|
311| TRAJECTORY_TRACKING | 0x302 | Trajectory tracking.<br>This option is applicable when your application needs to record user trajectories, for example, the track recording function of sports applications.<br>It mainly uses the GNSS positioning technology and therefore the power consumption is relatively high.|
312| CAR_HAILING | 0x303 | Ride hailing.<br>This option is applicable when your application needs to obtain the current location of a user who is hailing a taxi.<br>It mainly uses the GNSS positioning technology and therefore the power consumption is relatively high.|
313| DAILY_LIFE_SERVICE | 0x304 | Daily life services.<br>This option is applicable when your application only needs the approximate location in scenarios such as when the user is browsing news, shopping online, and ordering food.<br>It mainly uses the network positioning technology and therefore the power consumption is relatively low.|
314| 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.|
315
316
317## CountryCodeType
318
319Defines the country code source type.
320
321**System capability**: SystemCapability.Location.Location.Core
322
323| Name| Value| Description|
324| -------- | -------- | -------- |
325| COUNTRY_CODE_FROM_LOCALE | 1 | Country code obtained from the language configuration of the globalization module.|
326| COUNTRY_CODE_FROM_SIM | 2 | Country code obtained from the SIM card.|
327| COUNTRY_CODE_FROM_LOCATION | 3 | Country code obtained using the reverse geocoding function based on the user's location information.|
328| COUNTRY_CODE_FROM_NETWORK | 4 | Country code obtained from the cellular network registration information.|
329
330
331## CoordinateSystemType<sup>12+</sup>
332
333Enumerates coordinate system types.
334
335**System capability**: SystemCapability.Location.Location.Geofence
336
337| Name| Value| Description|
338| -------- | -------- | -------- |
339| WGS84 | 1 | World Geodetic System 1984, a coordinate system established for the use of the GPS.|
340| GCJ02 | 2 | GCJ-02, a coordinate system for the geographic information system developed by the State Bureau of Surveying and Mapping of China.|
341
342
343## GeofenceTransitionEvent<sup>12+</sup>
344
345Defines a geofence transition event.
346
347**System capability**: SystemCapability.Location.Location.Geofence
348
349| Name| Value| Description|
350| -------- | -------- | -------- |
351| GEOFENCE_TRANSITION_EVENT_ENTER  | 1 | Event indicating that a device moves into a geofence.|
352| GEOFENCE_TRANSITION_EVENT_EXIT  | 2 | Event indicating that a device moves out of a geofence.|
353| GEOFENCE_TRANSITION_EVENT_DWELL   | 4 | Event indicating that a device stays in a geofence for more than 10s.|
354
355
356## SatelliteConstellationCategory<sup>12+</sup>
357
358Enumerates satellite constellation types.
359
360**System capability**: SystemCapability.Location.Location.Gnss
361
362| Name| Value| Description|
363| -------- | -------- | -------- |
364| CONSTELLATION_CATEGORY_UNKNOWN   | 0 | Unknown type. This is the default value.|
365| CONSTELLATION_CATEGORY_GPS   | 1 | Global positioning system (GPS), a high-precision radio navigation positioning system made up of artificial earth satellites launched by the United States.|
366| CONSTELLATION_CATEGORY_SBAS    | 2 | Satellite-based augmentation system (SBAS), which supports wide-area or regional augmentation through the use of geostationary (GEO) satellites for broadcasting augmentation information, such as ephemeris error, satellite clock difference, and ionospheric delay, to users. It enhances the accuracy, integrity, and availability of basic global navigation satellite systems.|
367| CONSTELLATION_CATEGORY_GLONASS    | 3 | Global navigation satellite system (GLONASS), a Russia space-based satellite navigation system that provides a global coverage positioning service similar to the GPS.|
368| CONSTELLATION_CATEGORY_QZSS    | 4 | Quasi-Zenith satellite system (QZSS), a regional navigation satellite system developed by Japan to enhance and augment GPS coverage over Japan's territory.|
369| CONSTELLATION_CATEGORY_BEIDOU     | 5 | Beidou navigation satellite system (BNSS), a global satellite navigation system developed by China.|
370| CONSTELLATION_CATEGORY_GALILEO     | 6 | Galileo satellite navigation system (GALILEO), a global satellite navigation and positioning system developed and established by the European Union.|
371| CONSTELLATION_CATEGORY_IRNSS     | 7 | Indian regional navigation satellite system (IRNSS), an independent regional satellite navigation system developed and operated by India.|
372
373
374## SatelliteAdditionalInfo<sup>12+</sup>
375
376Enumerates the types of additional satellite information.
377
378**System capability**: SystemCapability.Location.Location.Gnss
379
380| Name| Value| Description|
381| -------- | -------- | -------- |
382| SATELLITES_ADDITIONAL_INFO_NULL  | 0 | No additional information. This is the default value.|
383| SATELLITES_ADDITIONAL_INFO_EPHEMERIS_DATA_EXIST  | 1 | Ephemeris data.|
384| SATELLITES_ADDITIONAL_INFO_ALMANAC_DATA_EXIST   | 2 | Almanac data.|
385| SATELLITES_ADDITIONAL_INFO_USED_IN_FIX   | 4 | Use of the satellite in the latest location resolution.|
386| SATELLITES_ADDITIONAL_INFO_CARRIER_FREQUENCY_EXIST   | 8 | Presence of carrier frequencies on the satellite.|
387
388
389## PowerConsumptionScenario<sup>12+</sup>
390
391Enumerates power consumption scenarios in a location request.
392
393**Atomic service API**: This API can be used in atomic services since API version 12.
394
395**System capability**: SystemCapability.Location.Location.Core
396
397| Name| Value| Description|
398| -------- | -------- | -------- |
399| HIGH_POWER_CONSUMPTION  | 0x601 | High power consumption.<br>The mode mainly uses the GNSS positioning technology. The system uses the network positioning technology as an alternative to provide the location service for your application until the GNSS can provide stable location results. During the continuous location process, the network positioning technology is used if the GNSS location result cannot be obtained within 30 seconds. This policy can lead to significant hardware resource consumption and power consumption.|
400| LOW_POWER_CONSUMPTION  | 0x602 | Low power consumption.<br>This mode is applicable when your application only needs the approximate location in scenarios such as when the user is browsing news, shopping online, and ordering food.<br>It mainly uses the network positioning technology and therefore the power consumption is relatively low.|
401| NO_POWER_CONSUMPTION   | 0x603 | No power consumption.<br>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.  |
402
403
404## UserActivityScenario<sup>12+</sup>
405
406Enumerates user activity scenarios in a location request.
407
408**Atomic service API**: This API can be used in atomic services since API version 12.
409
410**System capability**: SystemCapability.Location.Location.Core
411
412> **NOTE**
413>
414> If a single location or continuous location is initiated in the NAVIGATION, SPORT, or TRANSPORT scenario, the system uses the network positioning technology as an alternative to provide the location service for your application until the GNSS can provide stable location results. During the continuous location process, the network positioning technology is used if the GNSS location result cannot be obtained within 30 seconds.
415
416| Name| Value| Description|
417| -------- | -------- | -------- |
418| NAVIGATION  | 0x401 | Navigation scenario.<br>This option is applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking.<br>It mainly uses the GNSS positioning technology and therefore the power consumption is relatively high.|
419| SPORT  | 0x402 | Sport scenario.<br>This option is applicable when your application needs to record user trajectories, for example, the track recording function of sports applications.<br>It mainly uses the GNSS positioning technology and therefore the power consumption is relatively high.|
420| TRANSPORT   | 0x403 | Travel scenario.<br>This option is applicable to user travel scenarios, such as taxi hailing and public transportation.<br>This option mainly uses the GNSS positioning technology and therefore the power consumption is relatively high. |
421| DAILY_LIFE_SERVICE   | 0x404 | Daily life service scenario.<br>This option is applicable when your application only needs the approximate location in scenarios such as when the user is browsing news, shopping online, and ordering food.<br>It mainly uses the network positioning technology and therefore the power consumption is relatively low. |
422
423
424## LocatingPriority<sup>12+</sup>
425
426Enumerates priority types in a single location request.
427
428**Atomic service API**: This API can be used in atomic services since API version 12.
429
430**System capability**: SystemCapability.Location.Location.Core
431
432| Name| Value| Description|
433| -------- | -------- | -------- |
434| PRIORITY_ACCURACY  | 0x501 | Location accuracy.<br>This policy uses both the GNSS positioning and network positioning technologies and provides the most accurate location result within the specified period of time, which is the smaller one between [SingleLocationRequest](#singlelocationrequest12).locatingTimeoutMs and 30 seconds.<br>This policy can lead to significant hardware resource consumption and power consumption. |
435| PRIORITY_LOCATING_SPEED  | 0x502 | Fast location preferred. Use this policy if you want to obtain a location as fast as possible.<br>This policy uses the GNSS positioning and network positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios and provides the first obtained location result to your application. This policy can lead to significant hardware resource consumption and power consumption.|
436
437
438## LocationError<sup>12+</sup>
439
440Enumerates error codes in a continuous location request.
441
442**Atomic service API**: This API can be used in atomic services since API version 12.
443
444**System capability**: SystemCapability.Location.Location.Core
445
446| Name| Value| Description|
447| -------- | -------- | -------- |
448| LOCATING_FAILED_DEFAULT   | -1 |  Unknown type. This is the default value.|
449| LOCATING_FAILED_LOCATION_PERMISSION_DENIED   | -2 | Failed to verify the **ohos.permission.APPROXIMATELY_LOCATION** or **ohos.permission.LOCATION** permission.|
450| LOCATING_FAILED_BACKGROUND_PERMISSION_DENIED    | -3 | Failed to verify the location permission when the application is running in the background. For details about how to apply for the location permission, see [Applying for Location Permissions](../../device/location/location-guidelines.md#applying-for-location-permissions).|
451| LOCATING_FAILED_LOCATION_SWITCH_OFF    | -4 | Location switch turned off.|
452| LOCATING_FAILED_INTERNET_ACCESS_FAILURE    | -5 | Network access denied.|
453
454
455## LocationSourceType<sup>12+</sup>
456
457Defines the source of the location result.
458
459**Atomic service API**: This API can be used in atomic services since API version 12.
460
461**System capability**: SystemCapability.Location.Location.Core
462
463| Name| Value| Description|
464| -------- | -------- | -------- |
465| GNSS   | 1 |  GNSS positioning technology.|
466| NETWORK    | 2 | Network positioning technology.|
467| INDOOR     | 3 | Indoor high-precision positioning technology.|
468| RTK     | 4 | Outdoor high-precision positioning technology.|
469
470
471## geoLocationManager.on('locationChange')
472
473on(type: 'locationChange', request: LocationRequest | ContinuousLocationRequest, callback: Callback&lt;Location&gt;): void
474
475Subscribes to location change events with a location request initiated. This API uses an asynchronous callback to return the result.
476
477**Atomic service API**: This API can be used in atomic services since API version 11.
478
479**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
480
481**System capability**: SystemCapability.Location.Location.Core
482
483**Parameters**
484
485  | Name| Type| Mandatory| Description|
486  | -------- | -------- | -------- | -------- |
487  | type | string | Yes| Event type. The value **locationChange** indicates a location change.|
488  | request |  [LocationRequest](#locationrequest) &#124; [ContinuousLocationRequest](#continuouslocationrequest12) | Yes| Location request.<br>**ContinuousLocationRequest** is newly added in API version 12.|
489  | callback | Callback&lt;[Location](#location)&gt; | Yes| Callback used to return the result.|
490
491**Error codes**
492
493For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
494
495| ID| Error Message|
496| -------- | ---------------------------------------- |
497|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
498|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
499|801 | Capability not supported. Failed to call ${geoLocationManager.on('locationChange')} due to limited device capabilities.          |
500|3301000 | The location service is unavailable.                                           |
501|3301100 | The location switch is off.                                                 |
502|3301200 | Failed to obtain the geographical location.                                       |
503
504**Example**
505
506  ```ts
507  import { geoLocationManager } from '@kit.LocationKit';
508
509  // Method 1: Use LocationRequest as the input parameter.
510  let requestInfo:geoLocationManager.LocationRequest = {'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, 'scenario': geoLocationManager.LocationRequestScenario.UNSET, 'timeInterval': 1, 'distanceInterval': 0, 'maxAccuracy': 0};
511  let locationChange = (location:geoLocationManager.Location):void => {
512      console.info('locationChanger: data: ' + JSON.stringify(location));
513  };
514  try {
515      geoLocationManager.on('locationChange', requestInfo, locationChange);
516  } catch (err) {
517      console.error("errCode:" + err.code + ", message:"  + err.message);
518  }
519
520  // Method 2: Use ContinuousLocationRequest as the input parameter.
521  let request:geoLocationManager.ContinuousLocationRequest = {'interval': 1, 'locationScenario': geoLocationManager.UserActivityScenario.NAVIGATION};
522  let locationCallback = (location:geoLocationManager.Location):void => {
523      console.info('locationCallback: data: ' + JSON.stringify(location));
524  };
525  try {
526      geoLocationManager.on('locationChange', request, locationCallback);
527  } catch (err) {
528      console.error("errCode:" + err.code + ", message:"  + err.message);
529  }
530  ```
531
532
533## geoLocationManager.off('locationChange')
534
535off(type: 'locationChange', callback?: Callback&lt;Location&gt;): void
536
537Unregisters the listener for location change events with the corresponding location request deleted.
538
539**Atomic service API**: This API can be used in atomic services since API version 11.
540
541**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
542
543**System capability**: SystemCapability.Location.Location.Core
544
545**Parameters**
546
547  | Name| Type| Mandatory| Description|
548  | -------- | -------- | -------- | -------- |
549  | type | string | Yes| Event type. The value **locationChange** indicates a location change.|
550  | callback | Callback&lt;[Location](#location)&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.|
551
552**Error codes**
553
554For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
555
556| ID| Error Message|
557| -------- | ---------------------------------------- |
558|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
559|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
560|801 | Capability not supported. Failed to call ${geoLocationManager.off('locationChange')} due to limited device capabilities.          |
561|3301000 | The location service is unavailable.                                           |
562|3301100 | The location switch is off.                                                 |
563|3301200 | Failed to obtain the geographical location.                                       |
564
565**Example**
566
567  ```ts
568  import { geoLocationManager } from '@kit.LocationKit';
569
570  let requestInfo:geoLocationManager.LocationRequest = {'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, 'scenario': geoLocationManager.LocationRequestScenario.UNSET, 'timeInterval': 1, 'distanceInterval': 0, 'maxAccuracy': 0};
571  let locationChange = (location:geoLocationManager.Location):void => {
572    console.info('locationChanger: data: ' + JSON.stringify(location));
573  };
574  try {
575      geoLocationManager.on('locationChange', requestInfo, locationChange);
576      geoLocationManager.off('locationChange', locationChange);
577  } catch (err) {
578      console.error("errCode:" + err.code + ", message:"  + err.message);
579  }
580  ```
581
582
583## geoLocationManager.on('locationError')<sup>12+</sup>
584
585on(type: 'locationError', callback: Callback&lt;LocationError&gt;): void
586
587Registers a listener for error codes generated during continuous location. This API uses an asynchronous callback to return the result.
588
589**Atomic service API**: This API can be used in atomic services since API version 12.
590
591**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
592
593**System capability**: SystemCapability.Location.Location.Core
594
595**Parameters**
596
597  | Name| Type| Mandatory| Description|
598  | -------- | -------- | -------- | -------- |
599  | type | string | Yes| Event type. To subscribe to error codes generated during continuous location, set the value to **locationError**.|
600  | callback | Callback&lt;[LocationError](#locationerror12)&gt; | Yes| Callback used to return the result.|
601
602**Error codes**
603
604For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
605
606| ID| Error Message|
607| -------- | ---------------------------------------- |
608|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
609|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
610|801 | Capability not supported. Failed to call ${geoLocationManager.on('locationError')} due to limited device capabilities.          |
611|3301000 | The location service is unavailable.                                           |
612
613**Example**
614
615  ```ts
616  import { geoLocationManager } from '@kit.LocationKit';
617
618  let requestInfo:geoLocationManager.LocationRequest = {'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, 'scenario': geoLocationManager.LocationRequestScenario.UNSET, 'timeInterval': 1, 'distanceInterval': 0, 'maxAccuracy': 0};
619  let locationChange = (location:geoLocationManager.Location):void => {
620      console.info('locationChanger: data: ' + JSON.stringify(location));
621  };
622  try {
623      geoLocationManager.on('locationChange', requestInfo, locationChange);
624  } catch (err) {
625      console.error("errCode:" + err.code + ", message:"  + err.message);
626  }
627
628  let locationErrorChange = (errcode: geoLocationManager.LocationError):void => {
629    console.info('locationErrorChange: data: ' + JSON.stringify(errcode));
630  };
631  try {
632    geoLocationManager.on('locationError', locationErrorChange);
633  } catch (err) {
634    console.error("errCode:" + err.code + ", message:"  + err.message);
635  }
636
637  ```
638
639
640## geoLocationManager.off('locationError')<sup>12+</sup>
641
642off(type: 'locationError', callback?: Callback&lt;LocationError&gt;): void
643
644Unregisters the listener for error codes generated during continuous location.
645
646**Atomic service API**: This API can be used in atomic services since API version 12.
647
648**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
649
650**System capability**: SystemCapability.Location.Location.Core
651
652**Parameters**
653
654  | Name| Type| Mandatory| Description|
655  | -------- | -------- | -------- | -------- |
656  | type | string | Yes| Event type. To subscribe to error codes generated during continuous location, set the value to **locationError**.|
657  | callback | Callback&lt;[LocationError](#locationerror12)&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.|
658
659**Error codes**
660
661For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
662
663| ID| Error Message|
664| -------- | ---------------------------------------- |
665|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
666|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
667|801 | Capability not supported. Failed to call ${geoLocationManager.off('locationError')} due to limited device capabilities.          |
668|3301000 | The location service is unavailable.                                           |
669
670**Example**
671
672  ```ts
673  import { geoLocationManager } from '@kit.LocationKit';
674
675  let locationErrorChange = (errcode: geoLocationManager.LocationError):void => {
676    console.info('locationErrorChange: data: ' + JSON.stringify(errcode));
677  };
678  try {
679    geoLocationManager.on('locationError', locationErrorChange);
680    geoLocationManager.off('locationError', locationErrorChange);
681  } catch (err) {
682    console.error("errCode:" + err.code + ", message:"  + err.message);
683  }
684  ```
685
686
687## geoLocationManager.on('locationEnabledChange')
688
689on(type: 'locationEnabledChange', callback: Callback&lt;boolean&gt;): void
690
691Subscribes to location service status change events. This API uses an asynchronous callback to return the result.
692
693**System capability**: SystemCapability.Location.Location.Core
694
695**Parameters**
696
697  | Name| Type| Mandatory| Description|
698  | -------- | -------- | -------- | -------- |
699  | type | string | Yes| Event type. The value **locationEnabledChange** indicates a location service status change.|
700  | callback | Callback&lt;boolean&gt; | Yes| Callback used to return the result. The value **true** indicates that the location switch is enabled and the value **false** indicates the opposite.|
701
702**Error codes**
703
704For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
705
706| ID| Error Message|
707| -------- | ---------------------------------------- |
708|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
709|801 | Capability not supported. Failed to call ${geoLocationManager.on('locationEnabledChange')} due to limited device capabilities.          |
710|3301000 | The location service is unavailable.                                           |
711
712**Example**
713
714  ```ts
715  import { geoLocationManager } from '@kit.LocationKit';
716
717  let locationEnabledChange = (state:boolean):void => {
718      console.info('locationEnabledChange: ' + JSON.stringify(state));
719  }
720  try {
721      geoLocationManager.on('locationEnabledChange', locationEnabledChange);
722  } catch (err) {
723      console.error("errCode:" + err.code + ", message:"  + err.message);
724  }
725  ```
726
727
728## geoLocationManager.off('locationEnabledChange')
729
730off(type: 'locationEnabledChange', callback?: Callback&lt;boolean&gt;): void
731
732Unsubscribes from location service status change events.
733
734**System capability**: SystemCapability.Location.Location.Core
735
736**Parameters**
737
738  | Name| Type| Mandatory| Description|
739  | -------- | -------- | -------- | -------- |
740  | type | string | Yes| Event type. The value **locationEnabledChange** indicates a location service status change.|
741  | callback | Callback&lt;boolean&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.|
742
743**Error codes**
744
745For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
746
747| ID| Error Message|
748| -------- | ---------------------------------------- |
749|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
750|801 | Capability not supported. Failed to call ${geoLocationManager.off('locationEnabledChange')} due to limited device capabilities.          |
751|3301000 | The location service is unavailable.                                           |
752
753**Example**
754
755  ```ts
756  import { geoLocationManager } from '@kit.LocationKit';
757
758  let locationEnabledChange = (state:boolean):void => {
759      console.info('locationEnabledChange: state: ' + JSON.stringify(state));
760  }
761  try {
762      geoLocationManager.on('locationEnabledChange', locationEnabledChange);
763      geoLocationManager.off('locationEnabledChange', locationEnabledChange);
764  } catch (err) {
765      console.error("errCode:" + err.code + ", message:"  + err.message);
766  }
767  ```
768
769
770## geoLocationManager.on('cachedGnssLocationsChange')
771
772on(type: 'cachedGnssLocationsChange', request: CachedGnssLocationsRequest, callback: Callback&lt;Array&lt;Location&gt;&gt;): void
773
774Subscribes to cached GNSS location reports. This API is supported only by certain GNSS chip models. If the required chip model is not available, error code 801 (Capability not supported) will be reported. This API uses an asynchronous callback to return the result.
775
776**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
777
778**System capability**: SystemCapability.Location.Location.Gnss
779
780**Parameters**
781
782  | Name| Type| Mandatory| Description|
783  | -------- | -------- | -------- | -------- |
784  | type | string | Yes| Event type. The value **cachedGnssLocationsChange** indicates reporting of cached GNSS locations.|
785  | request |  [CachedGnssLocationsRequest](#cachedgnsslocationsrequest) | Yes| Request for reporting cached GNSS location.|
786  | callback | Callback&lt;Array&lt;[Location](#location)&gt;&gt; | Yes| Callback used to return the result.|
787
788**Error codes**
789
790For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
791
792| ID| Error Message|
793| -------- | ---------------------------------------- |
794|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
795|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
796|801 | Capability not supported. Failed to call ${geoLocationManager.on('cachedGnssLocationsChange')} due to limited device capabilities.          |
797|3301000 | The location service is unavailable.                                           |
798|3301100 | The location switch is off.                                                 |
799|3301200 | Failed to obtain the geographical location.                                       |
800
801**Example**
802
803  ```ts
804  import { geoLocationManager } from '@kit.LocationKit';
805
806  let cachedLocationsCb = (locations:Array<geoLocationManager.Location>):void => {
807      console.info('cachedGnssLocationsChange: locations: ' + JSON.stringify(locations));
808  }
809  let requestInfo:geoLocationManager.CachedGnssLocationsRequest = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true};
810  try {
811      geoLocationManager.on('cachedGnssLocationsChange', requestInfo, cachedLocationsCb);
812  } catch (err) {
813      console.error("errCode:" + err.code + ", message:"  + err.message);
814  }
815  ```
816
817
818## geoLocationManager.off('cachedGnssLocationsChange')
819
820off(type: 'cachedGnssLocationsChange', callback?: Callback&lt;Array&lt;Location&gt;&gt;): void
821
822Unsubscribes from cached GNSS location reports. This API is supported only by certain GNSS chip models. If the required chip model is not available, error code 801 (Capability not supported) will be reported.
823
824**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
825
826**System capability**: SystemCapability.Location.Location.Gnss
827
828**Parameters**
829
830  | Name| Type| Mandatory| Description|
831  | -------- | -------- | -------- | -------- |
832  | type | string | Yes| Event type. The value **cachedGnssLocationsChange** indicates reporting of cached GNSS locations.|
833  | callback | Callback&lt;Array&lt;[Location](#location)&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.|
834
835**Error codes**
836
837For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
838
839| ID| Error Message|
840| -------- | ---------------------------------------- |
841|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
842|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
843|801 | Capability not supported. Failed to call ${geoLocationManager.off('cachedGnssLocationsChange')} due to limited device capabilities.          |
844|3301000 | The location service is unavailable.                                           |
845|3301100 | The location switch is off.                                                 |
846|3301200 | Failed to obtain the geographical location.                                       |
847
848**Example**
849
850  ```ts
851  import { geoLocationManager } from '@kit.LocationKit';
852
853  let cachedLocationsCb = (locations:Array<geoLocationManager.Location>):void => {
854      console.info('cachedGnssLocationsChange: locations: ' + JSON.stringify(locations));
855  }
856  let requestInfo:geoLocationManager.CachedGnssLocationsRequest = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true};
857  try {
858      geoLocationManager.on('cachedGnssLocationsChange', requestInfo, cachedLocationsCb);
859      geoLocationManager.off('cachedGnssLocationsChange');
860  } catch (err) {
861      console.error("errCode:" + err.code + ", message:"  + err.message);
862  }
863  ```
864
865
866## geoLocationManager.on('satelliteStatusChange')
867
868on(type: 'satelliteStatusChange', callback: Callback&lt;SatelliteStatusInfo&gt;): void
869
870Subscribes to GNSS satellite status change events. This API uses an asynchronous callback to return the result.
871
872**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
873
874**System capability**: SystemCapability.Location.Location.Gnss
875
876**Parameters**
877
878  | Name| Type| Mandatory| Description|
879  | -------- | -------- | -------- | -------- |
880  | type | string | Yes| Event type. The value **satelliteStatusChange** indicates a GNSS satellite status change.|
881  | callback | Callback&lt;[SatelliteStatusInfo](#satellitestatusinfo)&gt; | Yes| Callback used to return the result.|
882
883**Error codes**
884
885For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
886
887| ID| Error Message|
888| -------- | ---------------------------------------- |
889|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
890|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
891|801 | Capability not supported. Failed to call ${geoLocationManager.on('satelliteStatusChange')} due to limited device capabilities.          |
892|3301000 | The location service is unavailable.                                           |
893|3301100 | The location switch is off.                                                 |
894
895**Example**
896
897  ```ts
898  import { geoLocationManager } from '@kit.LocationKit';
899
900  let gnssStatusCb = (satelliteStatusInfo:geoLocationManager.SatelliteStatusInfo):void => {
901      console.info('satelliteStatusChange: ' + JSON.stringify(satelliteStatusInfo));
902  }
903
904  try {
905      geoLocationManager.on('satelliteStatusChange', gnssStatusCb);
906  } catch (err) {
907      console.error("errCode:" + err.code + ", message:"  + err.message);
908  }
909  ```
910
911
912## geoLocationManager.off('satelliteStatusChange')
913
914off(type: 'satelliteStatusChange', callback?: Callback&lt;SatelliteStatusInfo&gt;): void
915
916Unsubscribes from GNSS satellite status change events.
917
918**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
919
920**System capability**: SystemCapability.Location.Location.Gnss
921
922**Parameters**
923
924  | Name| Type| Mandatory| Description|
925  | -------- | -------- | -------- | -------- |
926  | type | string | Yes| Event type. The value **satelliteStatusChange** indicates a GNSS satellite status change.|
927  | callback | Callback&lt;[SatelliteStatusInfo](#satellitestatusinfo)&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.|
928
929**Error codes**
930
931For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
932
933| ID| Error Message|
934| -------- | ---------------------------------------- |
935|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
936|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
937|801 | Capability not supported. Failed to call ${geoLocationManager.off('satelliteStatusChange')} due to limited device capabilities.          |
938|3301000 | The location service is unavailable.                                           |
939|3301100 | The location switch is off.                                                 |
940
941
942**Example**
943
944  ```ts
945  import { geoLocationManager } from '@kit.LocationKit';
946
947  let gnssStatusCb = (satelliteStatusInfo:geoLocationManager.SatelliteStatusInfo):void => {
948      console.info('satelliteStatusChange: ' + JSON.stringify(satelliteStatusInfo));
949  }
950  try {
951      geoLocationManager.on('satelliteStatusChange', gnssStatusCb);
952      geoLocationManager.off('satelliteStatusChange', gnssStatusCb);
953  } catch (err) {
954      console.error("errCode:" + err.code + ", message:"  + err.message);
955  }
956  ```
957
958
959## geoLocationManager.on('nmeaMessage')
960
961on(type: 'nmeaMessage', callback: Callback&lt;string&gt;): void
962
963Subscribes to GNSS NMEA message change events. This API uses an asynchronous callback to return the result.
964
965**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
966
967**System capability**: SystemCapability.Location.Location.Gnss
968
969**Parameters**
970
971  | Name| Type| Mandatory| Description|
972  | -------- | -------- | -------- | -------- |
973  | type | string | Yes| Event type. The value **nmeaMessage** indicates a GNSS NMEA message change.|
974  | callback | Callback&lt;string&gt; | Yes| Callback used to return the result.|
975
976**Error codes**
977
978For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
979
980| ID| Error Message|
981| -------- | ---------------------------------------- |
982|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
983|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
984|801 | Capability not supported. Failed to call ${geoLocationManager.on('nmeaMessage')} due to limited device capabilities.          |
985|3301000 | The location service is unavailable.                                           |
986|3301100 | The location switch is off.                                                 |
987
988
989**Example**
990
991  ```ts
992  import { geoLocationManager } from '@kit.LocationKit';
993
994  let nmeaCb = (str:string):void => {
995      console.info('nmeaMessage: ' + JSON.stringify(str));
996  }
997
998  try {
999      geoLocationManager.on('nmeaMessage', nmeaCb );
1000  } catch (err) {
1001      console.error("errCode:" + err.code + ", message:"  + err.message);
1002  }
1003  ```
1004
1005
1006## geoLocationManager.off('nmeaMessage')
1007
1008off(type: 'nmeaMessage', callback?: Callback&lt;string&gt;): void
1009
1010Unsubscribes from GNSS NMEA message change events.
1011
1012**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
1013
1014**System capability**: SystemCapability.Location.Location.Gnss
1015
1016**Parameters**
1017
1018  | Name| Type| Mandatory| Description|
1019  | -------- | -------- | -------- | -------- |
1020  | type | string | Yes| Event type. The value **nmeaMessage** indicates a GNSS NMEA message change.|
1021  | callback | Callback&lt;string&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.|
1022
1023**Error codes**
1024
1025For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1026
1027| ID| Error Message|
1028| -------- | ---------------------------------------- |
1029|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
1030|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1031|801 | Capability not supported. Failed to call ${geoLocationManager.off('nmeaMessage')} due to limited device capabilities.          |
1032|3301000 | The location service is unavailable.                                           |
1033|3301100 | The location switch is off.                                                 |
1034
1035
1036**Example**
1037
1038  ```ts
1039  import { geoLocationManager } from '@kit.LocationKit';
1040
1041  let nmeaCb = (str:string):void => {
1042      console.info('nmeaMessage: ' + JSON.stringify(str));
1043  }
1044
1045  try {
1046      geoLocationManager.on('nmeaMessage', nmeaCb);
1047      geoLocationManager.off('nmeaMessage', nmeaCb);
1048  } catch (err) {
1049      console.error("errCode:" + err.code + ", message:"  + err.message);
1050  }
1051  ```
1052
1053
1054## geoLocationManager.on('gnssFenceStatusChange')
1055
1056on(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): void
1057
1058Subscribes to status change events of the specified geofence. This API is supported only by certain GNSS chip models. If the required chip model is not available, error code 801 (Capability not supported) will be reported.
1059
1060**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
1061
1062**System capability**: SystemCapability.Location.Location.Geofence
1063
1064**Parameters**
1065
1066  | Name| Type| Mandatory| Description|
1067  | -------- | -------- | -------- | -------- |
1068  | type | string | Yes| Event type. The value **gnssFenceStatusChange** indicates a geofence status change.|
1069  | request |  [GeofenceRequest](#geofencerequest) | Yes| Geofencing request.|
1070  | want | [WantAgent](../apis-ability-kit/js-apis-app-ability-wantAgent.md) | Yes| **WantAgent** used to receive geofence (entrance or exit) events.|
1071
1072**Error codes**
1073
1074For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1075
1076| ID| Error Message|
1077| -------- | ---------------------------------------- |
1078|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
1079|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1080|801 | Capability not supported. Failed to call ${geoLocationManager.on('gnssFenceStatusChange')} due to limited device capabilities.          |
1081|3301000 | The location service is unavailable.                                           |
1082|3301100 | The location switch is off.                                                 |
1083|3301600 | Failed to operate the geofence.                                     |
1084
1085**Example**
1086
1087  ```ts
1088  import { geoLocationManager } from '@kit.LocationKit';
1089  import { wantAgent } from '@kit.AbilityKit';
1090
1091
1092  let wantAgentInfo:wantAgent.WantAgentInfo = {
1093      wants: [
1094          {
1095              bundleName: "com.example.myapplication",
1096              abilityName: "EntryAbility",
1097              action: "action1"
1098          }
1099      ],
1100      operationType: wantAgent.OperationType.START_ABILITY,
1101      requestCode: 0,
1102      wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
1103  };
1104
1105  wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
1106    let requestInfo:geoLocationManager.GeofenceRequest = {'scenario': 0x301, "geofence": {"latitude": 31.12, "longitude": 121.11, "radius": 100, "expiration": 10000}};
1107    try {
1108        geoLocationManager.on('gnssFenceStatusChange', requestInfo, wantAgentObj);
1109    } catch (err) {
1110        console.error("errCode:" + err.code + ", message:"  + err.message);
1111    }
1112  });
1113  ```
1114
1115
1116## geoLocationManager.off('gnssFenceStatusChange')
1117
1118off(type: 'gnssFenceStatusChange', request: GeofenceRequest, want: WantAgent): void
1119
1120Unsubscribes from status change events of the specified geofence. This API is supported only by certain GNSS chip models. If the required chip model is not available, error code 801 (Capability not supported) will be reported.
1121
1122**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
1123
1124**System capability**: SystemCapability.Location.Location.Geofence
1125
1126**Parameters**
1127
1128  | Name| Type| Mandatory| Description|
1129  | -------- | -------- | -------- | -------- |
1130  | type | string | Yes| Event type. The value **gnssFenceStatusChange** indicates a geofence status change.|
1131  | request | [GeofenceRequest](#geofencerequest) | Yes| Geofencing request.|
1132  | want | [WantAgent](../apis-ability-kit/js-apis-app-ability-wantAgent.md) | Yes| **WantAgent** used to receive geofence (entrance or exit) events.|
1133
1134**Error codes**
1135
1136For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1137
1138| ID| Error Message|
1139| -------- | ---------------------------------------- |
1140|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
1141|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1142|801 | Capability not supported. Failed to call ${geoLocationManager.off('gnssFenceStatusChange')} due to limited device capabilities.          |
1143|3301000 | The location service is unavailable.                                           |
1144|3301100 | The location switch is off.                                                 |
1145|3301600 | Failed to operate the geofence.                                     |
1146
1147**Example**
1148
1149  ```ts
1150  import { geoLocationManager } from '@kit.LocationKit';
1151  import { wantAgent } from '@kit.AbilityKit';
1152
1153
1154  let wantAgentInfo:wantAgent.WantAgentInfo = {
1155      wants: [
1156          {
1157              bundleName: "com.example.myapplication",
1158              abilityName: "EntryAbility",
1159              action: "action1",
1160          }
1161      ],
1162      operationType: wantAgent.OperationType.START_ABILITY,
1163      requestCode: 0,
1164      wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
1165  };
1166
1167  wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
1168    let requestInfo:geoLocationManager.GeofenceRequest = {'scenario': 0x301, "geofence": {"latitude": 31.12, "longitude": 121.11, "radius": 100, "expiration": 10000}};;
1169    try {
1170        geoLocationManager.on('gnssFenceStatusChange', requestInfo, wantAgentObj);
1171        geoLocationManager.off('gnssFenceStatusChange', requestInfo, wantAgentObj);
1172    } catch (err) {
1173        console.error("errCode:" + err.code + ", message:"  + err.message);
1174    }
1175  });
1176  ```
1177
1178
1179## geoLocationManager.on('countryCodeChange')
1180
1181on(type: 'countryCodeChange', callback: Callback&lt;CountryCode&gt;): void
1182
1183Subscribes to country code change events. This API uses an asynchronous callback to return the result.
1184
1185**System capability**: SystemCapability.Location.Location.Core
1186
1187**Parameters**
1188
1189  | Name| Type| Mandatory| Description|
1190  | -------- | -------- | -------- | -------- |
1191  | type | string | Yes| Event type. The value **countryCodeChange** indicates a country code change.|
1192  | callback | Callback&lt;[CountryCode](#countrycode)&gt; | Yes| Callback used to return the result.|
1193
1194**Error codes**
1195
1196For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1197
1198| ID| Error Message|
1199| -------- | ---------------------------------------- |
1200|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1201|801 | Capability not supported. Failed to call ${geoLocationManager.on('countryCodeChange')} due to limited device capabilities.          |
1202|3301000 | The location service is unavailable.                                           |
1203|3301500 | Failed to query the area information.                                       |
1204
1205
1206**Example**
1207
1208  ```ts
1209  import { geoLocationManager } from '@kit.LocationKit';
1210
1211  let callback = (code:geoLocationManager.CountryCode):void => {
1212      console.info('countryCodeChange: ' + JSON.stringify(code));
1213  }
1214
1215  try {
1216      geoLocationManager.on('countryCodeChange', callback);
1217  } catch (err) {
1218      console.error("errCode:" + err.code + ", message:"  + err.message);
1219  }
1220  ```
1221
1222
1223## geoLocationManager.off('countryCodeChange')
1224
1225off(type: 'countryCodeChange', callback?: Callback&lt;CountryCode&gt;): void
1226
1227Unsubscribes from country code change events.
1228
1229**System capability**: SystemCapability.Location.Location.Core
1230
1231**Parameters**
1232
1233  | Name| Type| Mandatory| Description|
1234  | -------- | -------- | -------- | -------- |
1235  | type | string | Yes| Event type. The value **countryCodeChange** indicates a country code change.|
1236  | callback | Callback&lt;[CountryCode](#countrycode)&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.|
1237
1238**Error codes**
1239
1240For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1241
1242| ID| Error Message|
1243| -------- | ---------------------------------------- |
1244|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1245|801 | Capability not supported. Failed to call ${geoLocationManager.off('countryCodeChange')} due to limited device capabilities.          |
1246|3301000 | The location service is unavailable.                                           |
1247|3301500 | Failed to query the area information.                                       |
1248
1249**Example**
1250
1251  ```ts
1252  import { geoLocationManager } from '@kit.LocationKit';
1253
1254  let callback = (code:geoLocationManager.CountryCode):void => {
1255      console.info('countryCodeChange: ' + JSON.stringify(code));
1256  }
1257
1258  try {
1259      geoLocationManager.on('countryCodeChange', callback);
1260      geoLocationManager.off('countryCodeChange', callback);
1261  } catch (err) {
1262      console.error("errCode:" + err.code + ", message:"  + err.message);
1263  }
1264  ```
1265
1266
1267## geoLocationManager.getCurrentLocation
1268
1269getCurrentLocation(request: CurrentLocationRequest | SingleLocationRequest, callback: AsyncCallback&lt;Location&gt;): void
1270
1271Obtains the current position. This API uses an asynchronous callback to return the result.
1272
1273**Atomic service API**: This API can be used in atomic services since API version 11.
1274
1275**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
1276
1277**System capability**: SystemCapability.Location.Location.Core
1278
1279**Parameters**
1280
1281  | Name| Type| Mandatory| Description|
1282  | -------- | -------- | -------- | -------- |
1283  | request | [CurrentLocationRequest](#currentlocationrequest) &#124;  [SingleLocationRequest](#singlelocationrequest12) | Yes| Location request.<br>**SingleLocationRequest** is newly added in API version 12.|
1284  | callback | AsyncCallback&lt;[Location](#location)&gt; | Yes| Callback used to return the result.|
1285
1286**Error codes**
1287
1288For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1289
1290| ID| Error Message|
1291| -------- | ---------------------------------------- |
1292|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
1293|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1294|801 | Capability not supported. Failed to call ${geoLocationManager.getCurrentLocation} due to limited device capabilities.          |
1295|3301000 | The location service is unavailable.                                           |
1296|3301100 | The location switch is off.                                                 |
1297|3301200 | Failed to obtain the geographical location.  |
1298
1299**Example**
1300
1301  ```ts
1302  import { geoLocationManager } from '@kit.LocationKit';
1303  import { BusinessError } from '@kit.BasicServicesKit';
1304  // Method 1: Use CurrentLocationRequest as the input parameter.
1305  let requestInfo:geoLocationManager.CurrentLocationRequest = {'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, 'scenario': geoLocationManager.LocationRequestScenario.UNSET,'maxAccuracy': 0};
1306  let locationChange = (err:BusinessError, location:geoLocationManager.Location):void => {
1307      if (err) {
1308          console.error('locationChanger: err=' + JSON.stringify(err));
1309      }
1310      if (location) {
1311          console.info('locationChanger: location=' + JSON.stringify(location));
1312      }
1313  };
1314
1315  try {
1316      geoLocationManager.getCurrentLocation(requestInfo, locationChange);
1317  } catch (err) {
1318      console.error("errCode:" + err.code + ", message:"  + err.message);
1319  }
1320
1321  // Method 2: Use SingleLocationRequest as the input parameter.
1322  let request:geoLocationManager.SingleLocationRequest = {'locatingTimeoutMs': 10000, 'locatingPriority': geoLocationManager.LocatingPriority.PRIORITY_ACCURACY};
1323  let locationCallback = (err:BusinessError, location:geoLocationManager.Location):void => {
1324      if (err) {
1325          console.error('locationChanger: err=' + JSON.stringify(err));
1326      }
1327      if (location) {
1328          console.info('locationChanger: location=' + JSON.stringify(location));
1329      }
1330  };
1331
1332  try {
1333      geoLocationManager.getCurrentLocation(request, locationCallback);
1334  } catch (err) {
1335      console.error("errCode:" + err.code + ", message:"  + err.message);
1336  }
1337  ```
1338
1339## geoLocationManager.getCurrentLocation
1340
1341getCurrentLocation(callback: AsyncCallback&lt;Location&gt;): void
1342
1343Obtains the current position. This API uses an asynchronous callback to return the result.
1344
1345**Atomic service API**: This API can be used in atomic services since API version 11.
1346
1347**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
1348
1349**System capability**: SystemCapability.Location.Location.Core
1350
1351**Parameters**
1352
1353  | Name| Type| Mandatory| Description|
1354  | -------- | -------- | -------- | -------- |
1355  | callback | AsyncCallback&lt;[Location](#location)&gt; | Yes| Callback used to return the result.|
1356
1357**Error codes**
1358
1359For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1360
1361| ID| Error Message|
1362| -------- | ---------------------------------------- |
1363|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
1364|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1365|801 | Capability not supported. Failed to call ${geoLocationManager.getCurrentLocation} due to limited device capabilities.          |
1366|3301000 | The location service is unavailable.                                           |
1367|3301100 | The location switch is off.                                                 |
1368|3301200 | Failed to obtain the geographical location.  |
1369
1370**Example**
1371
1372  ```ts
1373  import { geoLocationManager } from '@kit.LocationKit';
1374  import { BusinessError } from '@kit.BasicServicesKit';
1375  let locationChange = (err:BusinessError, location:geoLocationManager.Location) => {
1376      if (err) {
1377          console.error('locationChanger: err=' + JSON.stringify(err));
1378      }
1379      if (location) {
1380          console.info('locationChanger: location=' + JSON.stringify(location));
1381      }
1382  };
1383
1384  try {
1385      geoLocationManager.getCurrentLocation(locationChange);
1386  } catch (err) {
1387      console.error("errCode:" + err.code + ", message:"  + err.message);
1388  }
1389  ```
1390
1391## geoLocationManager.getCurrentLocation
1392
1393getCurrentLocation(request?: CurrentLocationRequest | SingleLocationRequest): Promise&lt;Location&gt;
1394
1395Obtains the current position. This API uses a promise to return the result.
1396
1397**Atomic service API**: This API can be used in atomic services since API version 11.
1398
1399**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
1400
1401**System capability**: SystemCapability.Location.Location.Core
1402
1403**Parameters**
1404
1405  | Name| Type| Mandatory| Description|
1406  | -------- | -------- | -------- | -------- |
1407  | request | [CurrentLocationRequest](#currentlocationrequest) &#124; [SingleLocationRequest](#singlelocationrequest12) | No| Location request.<br>**SingleLocationRequest** is newly added in API version 12.|
1408
1409**Return value**
1410
1411  | Type| Description|
1412  | -------- | -------- |
1413  | Promise&lt;[Location](#location)&gt; | Promise used to return the result.|
1414
1415**Error codes**
1416
1417For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1418
1419| ID| Error Message|
1420| -------- | ---------------------------------------- |
1421|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
1422|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1423|801 | Capability not supported. Failed to call ${geoLocationManager.getCurrentLocation} due to limited device capabilities.          |
1424|3301000 | The location service is unavailable.                                           |
1425|3301100 | The location switch is off.                                                 |
1426|3301200 | Failed to obtain the geographical location.  |
1427
1428**Example**
1429
1430  ```ts
1431  import { geoLocationManager } from '@kit.LocationKit';
1432  import { BusinessError } from '@kit.BasicServicesKit';
1433
1434  // Method 1: Use CurrentLocationRequest as the input parameter.
1435  let requestInfo:geoLocationManager.CurrentLocationRequest = {'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, 'scenario': geoLocationManager.LocationRequestScenario.UNSET,'maxAccuracy': 0};
1436  try {
1437      geoLocationManager.getCurrentLocation(requestInfo).then((result) => {
1438          console.info('current location: ' + JSON.stringify(result));
1439      })
1440      .catch((error:BusinessError) => {
1441          console.error('promise, getCurrentLocation: error=' + JSON.stringify(error));
1442      });
1443  } catch (err) {
1444      console.error("errCode:" + err.code + ", message:"  + err.message);
1445  }
1446
1447  // Method 2: Use SingleLocationRequest as the input parameter.
1448  let request:geoLocationManager.SingleLocationRequest = {'locatingTimeoutMs': 10000, 'locatingPriority': geoLocationManager.LocatingPriority.PRIORITY_ACCURACY};
1449  try {
1450      geoLocationManager.getCurrentLocation(request).then((result) => {
1451          console.info('current location: ' + JSON.stringify(result));
1452      })
1453      .catch((error:BusinessError) => {
1454          console.error('promise, getCurrentLocation: error=' + JSON.stringify(error));
1455      });
1456  } catch (err) {
1457      console.error("errCode:" + err.code + ", message:"  + err.message);
1458  }
1459  ```
1460
1461
1462## geoLocationManager.getLastLocation
1463
1464getLastLocation(): Location
1465
1466Obtains the last location.
1467
1468**Atomic service API**: This API can be used in atomic services since API version 11.
1469
1470**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
1471
1472**System capability**: SystemCapability.Location.Location.Core
1473
1474**Return value**
1475
1476  | Type| Description|
1477  | -------- | -------- |
1478  | [Location](#location) | Location information.|
1479
1480**Error codes**
1481
1482For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1483
1484| ID| Error Message|
1485| -------- | ---------------------------------------- |
1486|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
1487|801 | Capability not supported. Failed to call ${geoLocationManager.getLastLocation} due to limited device capabilities.          |
1488|3301000 | The location service is unavailable. |
1489|3301100 | The location switch is off.  |
1490|3301200 |Failed to obtain the geographical location.  |
1491
1492**Example**
1493
1494  ```ts
1495  import { geoLocationManager } from '@kit.LocationKit';
1496  try {
1497      let location = geoLocationManager.getLastLocation();
1498  } catch (err) {
1499      console.error("errCode:" + err.code + ", message:"  + err.message);
1500  }
1501  ```
1502
1503
1504## geoLocationManager.isLocationEnabled
1505
1506isLocationEnabled(): boolean
1507
1508Checks whether the location service is enabled.
1509
1510**Atomic service API**: This API can be used in atomic services since API version 11.
1511
1512**System capability**: SystemCapability.Location.Location.Core
1513
1514**Return value**
1515
1516  | Type| Description|
1517  | -------- | -------- |
1518  | boolean | **true**: The location switch is enabled.<br>**false**: The location switch is disabled.|
1519
1520**Error codes**
1521
1522For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1523
1524| ID| Error Message|
1525| -------- | ---------------------------------------- |
1526|801 | Capability not supported. Failed to call ${geoLocationManager.isLocationEnabled} due to limited device capabilities.          |
1527|3301000 | The location service is unavailable. |
1528
1529**Example**
1530
1531  ```ts
1532  import { geoLocationManager } from '@kit.LocationKit';
1533  try {
1534      let locationEnabled = geoLocationManager.isLocationEnabled();
1535  } catch (err) {
1536      console.error("errCode:" + err.code + ", message:"  + err.message);
1537  }
1538  ```
1539
1540
1541## geoLocationManager.getAddressesFromLocation
1542
1543getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;): void
1544
1545Converts coordinates into geographic descriptions through reverse geocoding. This API uses an asynchronous callback to return the result.
1546
1547**System capability**: SystemCapability.Location.Location.Geocoder
1548
1549**Parameters**
1550
1551  | Name| Type| Mandatory| Description|
1552  | -------- | -------- | -------- | -------- |
1553  | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Reverse geocoding request.|
1554  | callback | AsyncCallback&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Yes| Callback used to return the result.|
1555
1556**Error codes**
1557
1558For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1559
1560| ID| Error Message|
1561| -------- | ---------------------------------------- |
1562|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1563|801 | Capability not supported. Failed to call ${geoLocationManager.getAddressesFromLocation} due to limited device capabilities.          |
1564|3301000 | The location service is unavailable.  |
1565|3301300 | Reverse geocoding query failed.   |
1566
1567**Example**
1568
1569  ```ts
1570  import { geoLocationManager } from '@kit.LocationKit';
1571  let reverseGeocodeRequest:geoLocationManager.ReverseGeoCodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1};
1572  try {
1573      geoLocationManager.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => {
1574          if (err) {
1575              console.error('getAddressesFromLocation: err=' + JSON.stringify(err));
1576          }
1577          if (data) {
1578              console.info('getAddressesFromLocation: data=' + JSON.stringify(data));
1579          }
1580      });
1581  } catch (err) {
1582      console.error("errCode:" + err.code + ", message:"  + err.message);
1583  }
1584  ```
1585
1586
1587## geoLocationManager.getAddressesFromLocation
1588
1589getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise&lt;Array&lt;GeoAddress&gt;&gt;
1590
1591Converts coordinates into geographic descriptions through reverse geocoding. This API uses a promise to return the result.
1592
1593**System capability**: SystemCapability.Location.Location.Geocoder
1594
1595**Parameters**
1596
1597  | Name| Type| Mandatory| Description|
1598  | -------- | -------- | -------- | -------- |
1599  | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Reverse geocoding request.|
1600
1601**Return value**
1602
1603  | Type| Description|
1604  | -------- | -------- |
1605  | Promise&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Promise used to return the result.|
1606
1607**Error codes**
1608
1609For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1610
1611| ID| Error Message|
1612| -------- | ---------------------------------------- |
1613|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1614|801 | Capability not supported. Failed to call ${geoLocationManager.getAddressesFromLocation} due to limited device capabilities.          |
1615|3301000 | The location service is unavailable.  |
1616|3301300 | Reverse geocoding query failed.   |
1617
1618**Example**
1619
1620  ```ts
1621  import { geoLocationManager } from '@kit.LocationKit';
1622  import { BusinessError } from '@kit.BasicServicesKit';
1623  let reverseGeocodeRequest:geoLocationManager.ReverseGeoCodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1};
1624  try {
1625      geoLocationManager.getAddressesFromLocation(reverseGeocodeRequest).then((data) => {
1626          console.info('getAddressesFromLocation: ' + JSON.stringify(data));
1627      })
1628      .catch((error:BusinessError) => {
1629          console.error('promise, getAddressesFromLocation: error=' + JSON.stringify(error));
1630      });
1631  } catch (err) {
1632      console.error("errCode:" + err.code + ", message:"  + err.message);
1633  }
1634  ```
1635
1636
1637## geoLocationManager.getAddressesFromLocationName
1638
1639getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback&lt;Array&lt;GeoAddress&gt;&gt;): void
1640
1641Converts geographic descriptions into coordinates through geocoding. This API uses an asynchronous callback to return the result.
1642
1643**System capability**: SystemCapability.Location.Location.Geocoder
1644
1645**Parameters**
1646
1647  | Name| Type| Mandatory| Description|
1648  | -------- | -------- | -------- | -------- |
1649  | request | [GeoCodeRequest](#geocoderequest) | Yes| Geocoding request.|
1650  | callback | AsyncCallback&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Yes| Callback used to return the result.|
1651
1652**Error codes**
1653
1654For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1655
1656| ID| Error Message|
1657| -------- | ---------------------------------------- |
1658|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1659|801 | Capability not supported. Failed to call ${geoLocationManager.getAddressesFromLocationName} due to limited device capabilities.          |
1660|3301000 | The location service is unavailable.  |
1661|3301400 | Geocoding query failed.   |
1662
1663**Example**
1664
1665  ```ts
1666  import { geoLocationManager } from '@kit.LocationKit';
1667  let geocodeRequest:geoLocationManager.GeoCodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1};
1668  try {
1669      geoLocationManager.getAddressesFromLocationName(geocodeRequest, (err, data) => {
1670          if (err) {
1671              console.error('getAddressesFromLocationName: err=' + JSON.stringify(err));
1672          }
1673          if (data) {
1674              console.info('getAddressesFromLocationName: data=' + JSON.stringify(data));
1675          }
1676      });
1677  } catch (err) {
1678      console.error("errCode:" + err.code + ", message:"  + err.message);
1679  }
1680  ```
1681
1682
1683## geoLocationManager.getAddressesFromLocationName
1684
1685getAddressesFromLocationName(request: GeoCodeRequest): Promise&lt;Array&lt;GeoAddress&gt;&gt;
1686
1687Converts geographic descriptions into coordinates through geocoding. This API uses an a promise to return the result.
1688
1689**System capability**: SystemCapability.Location.Location.Geocoder
1690
1691**Parameters**
1692
1693  | Name| Type| Mandatory| Description|
1694  | -------- | -------- | -------- | -------- |
1695  | request | [GeoCodeRequest](#geocoderequest) | Yes| Geocoding request.|
1696
1697**Return value**
1698
1699  | Type| Description|
1700  | -------- | -------- |
1701  | Promise&lt;Array&lt;[GeoAddress](#geoaddress)&gt;&gt; | Promise used to return the result.|
1702
1703**Error codes**
1704
1705For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1706
1707| ID| Error Message|
1708| -------- | ---------------------------------------- |
1709|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1710|801 | Capability not supported. Failed to call ${geoLocationManager.getAddressesFromLocationName} due to limited device capabilities.          |
1711|3301000 | The location service is unavailable.  |
1712|3301400 | Geocoding query failed.   |
1713
1714**Example**
1715
1716  ```ts
1717  import { geoLocationManager } from '@kit.LocationKit';
1718  import { BusinessError } from '@kit.BasicServicesKit';
1719  let geocodeRequest:geoLocationManager.GeoCodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1};
1720  try {
1721      geoLocationManager.getAddressesFromLocationName(geocodeRequest).then((result) => {
1722          console.info('getAddressesFromLocationName: ' + JSON.stringify(result));
1723      })
1724      .catch((error:BusinessError) => {
1725          console.error('promise, getAddressesFromLocationName: error=' + JSON.stringify(error));
1726      });
1727  } catch (err) {
1728      console.error("errCode:" + err.code + ", message:"  + err.message);
1729  }
1730  ```
1731
1732## geoLocationManager.isGeocoderAvailable
1733
1734isGeocoderAvailable(): boolean
1735
1736Checks whether the geocoding and reverse geocoding services are available.
1737
1738**System capability**: SystemCapability.Location.Location.Geocoder
1739
1740**Return value**
1741
1742  | Type| Description|
1743  | -------- | -------- |
1744  | boolean | **true**: The geocoding and reverse geocoding services are available.<br>**false**: The geocoding and reverse geocoding services are unavailable.|
1745
1746**Error codes**
1747
1748For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1749
1750| ID| Error Message|
1751| -------- | ---------------------------------------- |
1752|801 | Capability not supported. Failed to call ${geoLocationManager.isGeocoderAvailable} due to limited device capabilities.          |
1753|3301000 | The location service is unavailable.  |
1754
1755**Example**
1756
1757  ```ts
1758  import { geoLocationManager } from '@kit.LocationKit';
1759  try {
1760      let isAvailable = geoLocationManager.isGeocoderAvailable();
1761  } catch (err) {
1762      console.error("errCode:" + err.code + ", message:"  + err.message);
1763  }
1764  ```
1765
1766
1767## geoLocationManager.getCachedGnssLocationsSize
1768
1769getCachedGnssLocationsSize(callback: AsyncCallback&lt;number&gt;): void
1770
1771Obtains the number of cached GNSS locations. This API is supported only by certain GNSS chip models. If the required chip model is not available, error code 801 (Capability not supported) will be reported. This API uses an asynchronous callback to return the result.
1772
1773**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
1774
1775**System capability**: SystemCapability.Location.Location.Gnss
1776
1777**Parameters**
1778
1779  | Name| Type| Mandatory| Description|
1780  | -------- | -------- | -------- | -------- |
1781  | callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the result.|
1782
1783**Error codes**
1784
1785For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1786
1787| ID| Error Message|
1788| -------- | ---------------------------------------- |
1789|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
1790|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1791|801 | Capability not supported. Failed to call ${geoLocationManager.getCachedGnssLocationsSize} due to limited device capabilities.          |
1792|3301000 | The location service is unavailable.  |
1793|3301100 | The location switch is off.   |
1794
1795**Example**
1796
1797  ```ts
1798  import { geoLocationManager } from '@kit.LocationKit';
1799  try {
1800      geoLocationManager.getCachedGnssLocationsSize((err, size) => {
1801          if (err) {
1802              console.error('getCachedGnssLocationsSize: err=' + JSON.stringify(err));
1803          }
1804          if (size) {
1805              console.info('getCachedGnssLocationsSize: size=' + JSON.stringify(size));
1806          }
1807      });
1808  } catch (err) {
1809      console.error("errCode:" + err.code + ", message:"  + err.message);
1810  }
1811  ```
1812
1813
1814## geoLocationManager.getCachedGnssLocationsSize
1815
1816getCachedGnssLocationsSize(): Promise&lt;number&gt;
1817
1818Obtains the number of cached GNSS locations. This API is supported only by certain GNSS chip models. If the required chip model is not available, error code 801 (Capability not supported) will be reported. This API uses a promise to return the result.
1819
1820**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
1821
1822**System capability**: SystemCapability.Location.Location.Gnss
1823
1824**Return value**
1825
1826  | Type| Description|
1827  | -------- | -------- |
1828  | Promise&lt;number&gt; | Promise used to return the result.|
1829
1830**Error codes**
1831
1832For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1833
1834| ID| Error Message|
1835| -------- | ---------------------------------------- |
1836|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
1837|801 | Capability not supported. Failed to call ${geoLocationManager.getCachedGnssLocationsSize} due to limited device capabilities.          |
1838|3301000 | The location service is unavailable.  |
1839|3301100 | The location switch is off.   |
1840
1841**Example**
1842
1843  ```ts
1844  import { geoLocationManager } from '@kit.LocationKit';
1845  import { BusinessError } from '@kit.BasicServicesKit';
1846  try {
1847      geoLocationManager.getCachedGnssLocationsSize().then((result) => {
1848          console.info('promise, getCachedGnssLocationsSize: ' + JSON.stringify(result));
1849      })
1850      .catch((error:BusinessError) => {
1851          console.error('promise, getCachedGnssLocationsSize: error=' + JSON.stringify(error));
1852      });
1853  } catch (err) {
1854      console.error("errCode:" + err.code + ", message:"  + err.message);
1855  }
1856  ```
1857
1858
1859## geoLocationManager.flushCachedGnssLocations
1860
1861flushCachedGnssLocations(callback: AsyncCallback&lt;void&gt;): void
1862
1863Obtains all cached GNSS locations and clears the GNSS cache queue. This API is supported only by certain GNSS chip models. If the required chip model is not available, error code 801 (Capability not supported) will be reported. This API uses an asynchronous callback to return the result.
1864
1865**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
1866
1867**System capability**: SystemCapability.Location.Location.Gnss
1868
1869**Parameters**
1870
1871  | Name| Type| Mandatory| Description|
1872  | -------- | -------- | -------- | -------- |
1873  | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
1874
1875**Error codes**
1876
1877For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1878
1879| ID| Error Message|
1880| -------- | ---------------------------------------- |
1881|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
1882|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1883|801 | Capability not supported. Failed to call ${geoLocationManager.flushCachedGnssLocations} due to limited device capabilities.          |
1884|3301000 | The location service is unavailable.  |
1885|3301100 | The location switch is off.   |
1886|3301200 | Failed to obtain the geographical location.   |
1887
1888**Example**
1889
1890  ```ts
1891  import { geoLocationManager } from '@kit.LocationKit';
1892  try {
1893      geoLocationManager.flushCachedGnssLocations((err) => {
1894          if (err) {
1895              console.error('flushCachedGnssLocations: err=' + JSON.stringify(err));
1896          }
1897      });
1898  } catch (err) {
1899      console.error("errCode:" + err.code + ", message:"  + err.message);
1900  }
1901  ```
1902
1903
1904## geoLocationManager.flushCachedGnssLocations
1905
1906flushCachedGnssLocations(): Promise&lt;void&gt;
1907
1908Obtains all cached GNSS locations and clears the GNSS cache queue. This API is supported only by certain GNSS chip models. If the required chip model is not available, error code 801 (Capability not supported) will be reported. This API uses a promise to return the result.
1909
1910**Permission required**: ohos.permission.APPROXIMATELY_LOCATION
1911
1912**System capability**: SystemCapability.Location.Location.Gnss
1913
1914**Return value**
1915
1916  | Type| Description|
1917  | -------- | -------- |
1918  | Promise&lt;void&gt; | Promise that returns no value.|
1919
1920**Error codes**
1921
1922For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1923
1924| ID| Error Message|
1925| -------- | ---------------------------------------- |
1926|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
1927|801 | Capability not supported. Failed to call ${geoLocationManager.flushCachedGnssLocations} due to limited device capabilities.          |
1928|3301000 | The location service is unavailable.  |
1929|3301100 | The location switch is off.   |
1930|3301200 | Failed to obtain the geographical location.   |
1931
1932**Example**
1933
1934  ```ts
1935  import { geoLocationManager } from '@kit.LocationKit';
1936  import { BusinessError } from '@kit.BasicServicesKit';
1937  try {
1938      geoLocationManager.flushCachedGnssLocations().then(() => {
1939          console.info('promise, flushCachedGnssLocations success');
1940      })
1941      .catch((error:BusinessError) => {
1942          console.error('promise, flushCachedGnssLocations: error=' + JSON.stringify(error));
1943      });
1944  } catch (err) {
1945      console.error("errCode:" + err.code + ", message:"  + err.message);
1946  }
1947  ```
1948
1949
1950## geoLocationManager.sendCommand
1951
1952sendCommand(command: LocationCommand, callback: AsyncCallback&lt;void&gt;): void
1953
1954Sends an extended command to the location subsystem. This API uses an asynchronous callback to return the result.
1955
1956**System capability**: SystemCapability.Location.Location.Core
1957
1958**Parameters**
1959
1960  | Name| Type| Mandatory| Description|
1961  | -------- | -------- | -------- | -------- |
1962  | command |  [LocationCommand](#locationcommand) | Yes| Extended command (string) to be sent.|
1963  | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
1964
1965**Error codes**
1966
1967For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
1968
1969| ID| Error Message|
1970| -------- | ---------------------------------------- |
1971|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
1972|801 | Capability not supported. Failed to call ${geoLocationManager.sendCommand} due to limited device capabilities.          |
1973|3301000 | The location service is unavailable.  |
1974
1975**Example**
1976
1977  ```ts
1978  import { geoLocationManager } from '@kit.LocationKit';
1979  let requestInfo:geoLocationManager.LocationCommand = {'scenario': 0x301, 'command': "command_1"};
1980  try {
1981      geoLocationManager.sendCommand(requestInfo, (err) => {
1982          if (err) {
1983              console.error('sendCommand: err=' + JSON.stringify(err));
1984          }
1985      });
1986  } catch (err) {
1987      console.error("errCode:" + err.code + ", message:"  + err.message);
1988  }
1989  ```
1990
1991
1992## geoLocationManager.sendCommand
1993
1994sendCommand(command: LocationCommand): Promise&lt;void&gt;
1995
1996Sends an extended command to the location subsystem. This API uses a promise to return the result.
1997
1998**System capability**: SystemCapability.Location.Location.Core
1999
2000**Parameters**
2001
2002  | Name| Type| Mandatory| Description|
2003  | -------- | -------- | -------- | -------- |
2004  | command | [LocationCommand](#locationcommand) | Yes| Extended command (string) to be sent.|
2005
2006**Return value**
2007
2008  | Type| Description|
2009  | -------- | -------- |
2010  | Promise&lt;void&gt; | Promise that returns no value.|
2011
2012**Error codes**
2013
2014For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
2015
2016| ID| Error Message|
2017| -------- | ---------------------------------------- |
2018|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
2019|801 | Capability not supported. Failed to call ${geoLocationManager.sendCommand} due to limited device capabilities.          |
2020|3301000 | The location service is unavailable.                                           |
2021
2022**Example**
2023
2024  ```ts
2025  import { geoLocationManager } from '@kit.LocationKit';
2026  import { BusinessError } from '@kit.BasicServicesKit';
2027  let requestInfo:geoLocationManager.LocationCommand = {'scenario': 0x301, 'command': "command_1"};
2028  try {
2029      geoLocationManager.sendCommand(requestInfo).then(() => {
2030          console.info('promise, sendCommand success');
2031      })
2032      .catch((error:BusinessError) => {
2033          console.error('promise, sendCommand: error=' + JSON.stringify(error));
2034      });
2035  } catch (err) {
2036      console.error("errCode:" + err.code + ", message:"  + err.message);
2037  }
2038  ```
2039
2040
2041## geoLocationManager.getCountryCode
2042
2043getCountryCode(callback: AsyncCallback&lt;CountryCode&gt;): void
2044
2045Obtains the current country code. This API uses an asynchronous callback to return the result.
2046
2047**System capability**: SystemCapability.Location.Location.Core
2048
2049**Parameters**
2050
2051  | Name| Type| Mandatory| Description|
2052  | -------- | -------- | -------- | -------- |
2053  | callback | AsyncCallback&lt;[CountryCode](#countrycode)&gt; | Yes| Callback used to return the result.|
2054
2055**Error codes**
2056
2057For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
2058
2059| ID| Error Message|
2060| -------- | ---------------------------------------- |
2061|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
2062|801 | Capability not supported. Failed to call ${geoLocationManager.getCountryCode} due to limited device capabilities.          |
2063|3301000 | The location service is unavailable.                                           |
2064|3301500 | Failed to query the area information.|
2065
2066**Example**
2067
2068  ```ts
2069  import { geoLocationManager } from '@kit.LocationKit';
2070  try {
2071      geoLocationManager.getCountryCode((err, result) => {
2072          if (err) {
2073              console.error('getCountryCode: err=' + JSON.stringify(err));
2074          }
2075          if (result) {
2076              console.info('getCountryCode: result=' + JSON.stringify(result));
2077          }
2078      });
2079  } catch (err) {
2080      console.error("errCode:" + err.code + ", message:"  + err.message);
2081  }
2082  ```
2083
2084
2085## geoLocationManager.getCountryCode
2086
2087getCountryCode(): Promise&lt;CountryCode&gt;
2088
2089Obtains the current country code. This API uses a promise to return the result.
2090
2091**System capability**: SystemCapability.Location.Location.Core
2092
2093**Return value**
2094
2095  | Type| Description|
2096  | -------- | -------- |
2097  | Promise&lt;[CountryCode](#countrycode)&gt; | Promise used to return the result.|
2098
2099**Error codes**
2100
2101For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
2102
2103| ID| Error Message|
2104| -------- | ---------------------------------------- |
2105|801 | Capability not supported. Failed to call ${geoLocationManager.getCountryCode} due to limited device capabilities.          |
2106|3301000 | The location service is unavailable.                                           |
2107|3301500 | Failed to query the area information.|
2108
2109**Example**
2110
2111  ```ts
2112  import { geoLocationManager } from '@kit.LocationKit';
2113  import { BusinessError } from '@kit.BasicServicesKit';
2114  try {
2115      geoLocationManager.getCountryCode()
2116      .then((result) => {
2117          console.info('promise, getCountryCode: result=' + JSON.stringify(result));
2118      })
2119      .catch((error:BusinessError) => {
2120          console.error('promise, getCountryCode: error=' + JSON.stringify(error));
2121      });
2122  } catch (err) {
2123      console.error("errCode:" + err.code + ", message:"  + err.message);
2124  }
2125  ```
2126
2127## geoLocationManager.addGnssGeofence<sup>12+</sup>
2128
2129addGnssGeofence(fenceRequest: GnssGeofenceRequest): Promise&lt;number&gt;
2130
2131Adds a GNSS geofence and subscribes to geofence transition events. This API uses a promise to return the result.
2132
2133The application can pass a callback to [GnssGeofenceRequest](#gnssgeofencerequest12) to receive geofence transition events. It can also pass [NotificationRequest](../apis-notification-kit/js-apis-notification.md#notificationrequest) so that a notification is displayed when a geofence transition event occurs.
2134
2135This API is supported only by certain GNSS chip models. If the required chip model is not available, error code 801 (Capability not supported) will be reported.
2136
2137**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
2138
2139**System capability**: SystemCapability.Location.Location.Geofence
2140
2141**Parameters**
2142
2143  | Name| Type| Mandatory| Description|
2144  | -------- | -------- | -------- | -------- |
2145  | fenceRequest | [GnssGeofenceRequest](#gnssgeofencerequest12) | Yes| Geofence request.<br>It includes the geofence information, list of geofence transition events and notifications, and callback used to receive geofence transition events.|
2146
2147**Return value**
2148
2149  | Type| Description|
2150  | -------- | -------- |
2151  | Promise&lt;number&gt; | Promise used to return the result.|
2152
2153**Error codes**
2154
2155For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
2156
2157| ID| Error Message|
2158| -------- | ---------------------------------------- |
2159|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
2160|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
2161|801 | Capability not supported. Failed to call ${geoLocationManager.addGnssGeofence} due to limited device capabilities.          |
2162|3301000 | The location service is unavailable.|
2163|3301100  | The location switch is off.|
2164|3301601   | The number of geofences exceeds the maximum.|
2165
2166**Example**
2167
2168  ```ts
2169  import { geoLocationManager } from '@kit.LocationKit';
2170  import { BusinessError } from '@kit.BasicServicesKit';
2171  import { notificationManager } from '@kit.NotificationKit';
2172  // Create a geofence.
2173  let geofence: geoLocationManager.Geofence = {
2174    "latitude": 34.12, "longitude": 124.11, "radius": 10000.0, "expiration": 10000.0
2175  }
2176  // Specify the types of geofence transition events to listen for. Geofence entry and exit events are used as an example.
2177  let transitionStatusList: Array<geoLocationManager.GeofenceTransitionEvent> = [
2178    geoLocationManager.GeofenceTransitionEvent.GEOFENCE_TRANSITION_EVENT_ENTER,
2179    geoLocationManager.GeofenceTransitionEvent.GEOFENCE_TRANSITION_EVENT_EXIT,
2180  ];
2181  // Create a notification object for GEOFENCE_TRANSITION_EVENT_ENTER.
2182  let notificationRequest1: notificationManager.NotificationRequest = {
2183    id: 1,
2184    content: {
2185      notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
2186      normal: {
2187        title: "Geofence Notification",
2188        text: "Geofence Entry",
2189        additionalText: ""
2190      }
2191    }
2192  };
2193  // Create a notification object for GEOFENCE_TRANSITION_EVENT_EXIT.
2194  let notificationRequest2: notificationManager.NotificationRequest = {
2195    id: 2,
2196    content: {
2197      notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
2198      normal: {
2199        title: "Geofence Notification",
2200        text:'Geofence Exit',
2201        additionalText: ""
2202      }
2203    }
2204  };
2205  // Save the created notification objects to Array in the same sequence as in transitionStatusList.
2206  let notificationRequestList: Array<notificationManager.NotificationRequest> =
2207    [notificationRequest1, notificationRequest2];
2208  // Construct a gnssGeofenceRequest object.
2209  let gnssGeofenceRequest: geoLocationManager.GnssGeofenceRequest = {
2210    // Geofence attributes, including the circle center and radius.
2211    geofence: geofence,
2212    // Specify the types of geofence transition events to listen for.
2213    monitorTransitionEvents: transitionStatusList,
2214    // Specify the notification objects for geofence transition events. This parameter is optional.
2215    notifications: notificationRequestList,
2216    // Specify the callback used to receive geofence transition events.
2217    geofenceTransitionCallback: (err : BusinessError, transition : geoLocationManager.GeofenceTransition) => {
2218      if (err) {
2219        console.error('geofenceTransitionCallback: err=' + JSON.stringify(err));
2220      }
2221      if (transition) {
2222        console.info("GeofenceTransition: %{public}s", JSON.stringify(transition));
2223    }
2224    }
2225  }
2226  try {
2227    // Add a geofence.
2228    geoLocationManager.addGnssGeofence(gnssGeofenceRequest).then((id) => {
2229      // Obtain the geofence ID after the geofence is successfully added.
2230      console.info("addGnssGeofence success, fence id: " + id);
2231      let fenceId = id;
2232    }).catch((err: BusinessError) => {
2233      console.error("addGnssGeofence failed, promise errCode:" + (err as BusinessError).code +
2234        ",errMessage:" + (err as BusinessError).message);
2235    });
2236  } catch(error) {
2237      console.error("addGnssGeofence failed, err:" + JSON.stringify(error));
2238  }
2239  ```
2240
2241
2242## geoLocationManager.removeGnssGeofence<sup>12+</sup>
2243
2244removeGnssGeofence(geofenceId: number): Promise&lt;void&gt;
2245
2246Removes a GNSS geofence and unsubscribes from geofence transition events. This API uses a promise to return the result.
2247
2248This API is supported only by certain GNSS chip models. If the required chip model is not available, error code 801 (Capability not supported) will be reported.
2249
2250**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
2251
2252**System capability**: SystemCapability.Location.Location.Geofence
2253
2254**Parameters**
2255
2256  | Name| Type| Mandatory| Description|
2257  | -------- | -------- | -------- | -------- |
2258  | geofenceId | number | Yes| GNSS geofence ID.|
2259
2260**Return value**
2261
2262  | Type| Description|
2263  | -------- | -------- |
2264  | Promise&lt;void&gt; | Promise that that returns no value.|
2265
2266**Error codes**
2267
2268For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
2269
2270| ID| Error Message|
2271| -------- | ---------------------------------------- |
2272|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
2273|401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.                 |
2274|801 | Capability not supported. Failed to call ${geoLocationManager.removeGnssGeofence} due to limited device capabilities.          |
2275|3301000 | The location service is unavailable. |
2276|3301602 | Failed to delete a geofence due to an incorrect ID. |
2277
2278**Example**
2279
2280  ```ts
2281  import { geoLocationManager } from '@kit.LocationKit';
2282  import { BusinessError } from '@kit.BasicServicesKit';
2283  // fenceId is obtained after geoLocationManager.addGnssGeofence is successfully executed.
2284  let fenceId = 1;
2285  try {
2286    geoLocationManager.removeGnssGeofence(fenceId).then(() => {
2287      console.info("removeGnssGeofence success fenceId:" + fenceId);
2288    }).catch((error : BusinessError) => {
2289      console.error("removeGnssGeofence: error=" + JSON.stringify(error));
2290    });
2291  } catch(error) {
2292    console.error("removeGnssGeofence: error=" + JSON.stringify(error));
2293  }
2294  ```
2295
2296
2297## geoLocationManager.getGeofenceSupportedCoordTypes<sup>12+</sup>
2298
2299getGeofenceSupportedCoordTypes(): Array&lt;CoordinateSystemType&gt;
2300
2301Obtains the list of supported coordinate systems.
2302
2303**System capability**: SystemCapability.Location.Location.Geofence
2304
2305**Return value**
2306
2307  | Type| Description|
2308  | -------- | -------- |
2309  | Array&lt;[CoordinateSystemType](#coordinatesystemtype12)&gt; | List of supported coordinate systems.|
2310
2311**Error codes**
2312
2313For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
2314
2315| ID| Error Message|
2316| -------- | ---------------------------------------- |
2317|801 | Capability not supported. Failed to call ${geoLocationManager.getGeofenceSupportedCoordTypes} due to limited device capabilities.          |
2318|3301000 | The location service is unavailable. |
2319
2320**Example**
2321
2322  ```ts
2323  import { geoLocationManager } from '@kit.LocationKit';
2324  try {
2325    let supportedCoordTypes: Array<geoLocationManager.CoordinateSystemType> = geoLocationManager.getGeofenceSupportedCoordTypes();
2326    console.info("getGeofenceSupportedCoordTypes return:" + JSON.stringify(supportedCoordTypes));
2327  } catch(error) {
2328    console.error("getGeofenceSupportedCoordTypes: error=" + JSON.stringify(error));
2329  }
2330  ```
2331
2332
2333## geoLocationManager.getCurrentWifiBssidForLocating<sup>14+</sup>
2334
2335getCurrentWifiBssidForLocating(): string
2336
2337Obtains the Basic Service Set Identifier (BSSID) of the connected Wi-Fi access point (AP).
2338
2339**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
2340
2341**System capability**: SystemCapability.Location.Location.Core
2342
2343**Return value**
2344
2345  | Type| Description|
2346  | -------- | -------- |
2347  | string | Wi-Fi Bssid |
2348
2349**Error codes**
2350
2351For details about the error codes, see [Location Error Codes]](errorcode-geoLocationManager.md).
2352
2353| ID| Error Message|
2354| -------- | ---------------------------------------- |
2355|201 | Permission verification failed. The application does not have the permission required to call the API.                 |
2356|801 | Capability not supported.Failed to call function due to limited device capabilities.          |
2357|3301000 | The location service is unavailable.                                           |
2358|3301100 | The location switch is off.                                                 |
2359|3301900 | Failed to obtain the hotpot MAC address because the Wi-Fi is not connected. |
2360
2361**Example**
2362
2363  ```ts
2364  import { geoLocationManager } from '@kit.LocationKit';
2365  try {
2366    let bssid: string = geoLocationManager.getCurrentWifiBssidForLocating();
2367    console.info("get wifi bssid:" + bssid);
2368  } catch(error) {
2369    console.error("getCurrentWifiBssidForLocating: errCode" + error.code + ", errMessage" + error.message);
2370  }
2371  ```
2372