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