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