• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Location Subsystem Changelog
2
3## cl.location.1 API Migration from @ohos.geolocation.d.ts to @ohos.geoLocationManager.d.ts
4
5APIs in **@ohos.geolocation.d.ts** do not support throwing error codes. To support this function, all APIs in **@ohos.geolocation.d.ts** are migrated to the newly added **@ohos.geoLocationManager.d.ts** file, and corresponding error code description is added.
6
7To use APIs of the location subsystem, you need to import **@ohos.geoLocationManager**.
8
9import geoLocationManager from '@ohos.geoLocationManager';
10
11
12**Change Impact**
13
14All APIs of the location subsystem are affected. To ensure normal use of these APIs, you need to import **@ohos.geoLocationManager**.
15
16import geoLocationManager from '@ohos.geoLocationManager';
17
18**Key API/Component Changes**
19
20| Class| API Type| Declaration| Change Type|
21|  -- | -- | -- | -- |
22|geolocation| namespace | declare namespace geolocation| Migrated to **@ohos.geoLocationManager.d.ts** and replaced by **namespace geoLocationManager**.|
23|geolocation| method | function on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
24|geolocation| method | function off(type: 'locationChange', callback?: Callback<Location>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
25|geolocation| method | function on(type: 'locationServiceState', callback: Callback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
26|geolocation| method | function off(type: 'locationServiceState', callback?: Callback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
27|geolocation| method | function on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback<Array<Location>>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
28|geolocation| method | function off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
29|geolocation| method | function on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
30|geolocation| method | function off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
31|geolocation| method | function on(type: 'nmeaMessageChange', callback: Callback<string>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
32|geolocation| method | function off(type: 'nmeaMessageChange', callback?: Callback<string>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
33|geolocation| method | function on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
34|geolocation| method | function off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
35|geolocation| method | function getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
36|geolocation| method | function getCurrentLocation(callback: AsyncCallback<Location>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
37|geolocation| method | function getCurrentLocation(request?: CurrentLocationRequest): Promise<Location>; | Migrated to **@ohos.geoLocationManager.d.ts**.|
38|geolocation| method | function getLastLocation(callback: AsyncCallback<Location>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
39|geolocation| method | function getLastLocation(): Promise<Location>; | Migrated to **@ohos.geoLocationManager.d.ts**.|
40|geolocation| method | function isLocationEnabled(callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
41|geolocation| method | function isLocationEnabled(): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts**.|
42|geolocation| method | function requestEnableLocation(callback: AsyncCallback<boolean>): void; | Deleted.|
43|geolocation| method | function requestEnableLocation(): Promise<boolean>; | Deleted.|
44|geolocation| method | function enableLocation(callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
45|geolocation| method | function enableLocation(): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts**.|
46|geolocation| method | function disableLocation(callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
47|geolocation| method | function disableLocation(): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts**.|
48|geolocation| method | function getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
49|geolocation| method | function getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<GeoAddress>>; | Migrated to **@ohos.geoLocationManager.d.ts**.|
50|geolocation| method | function getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
51|geolocation| method | function getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAddress>>; | Migrated to **@ohos.geoLocationManager.d.ts**.|
52|geolocation| method | function isGeoServiceAvailable(callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
53|geolocation| method | function isGeoServiceAvailable(): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts**.|
54|geolocation| method | function getCachedGnssLocationsSize(callback: AsyncCallback<number>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
55|geolocation| method | function getCachedGnssLocationsSize(): Promise<number>; | Migrated to **@ohos.geoLocationManager.d.ts**.|
56|geolocation| method | function flushCachedGnssLocations(callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
57|geolocation| method | function flushCachedGnssLocations(): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts**.|
58|geolocation| method | function sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.|
59|geolocation| method | function sendCommand(command: LocationCommand): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts**.|
60|geolocation| interface | SatelliteStatusInfo | Migrated to **@ohos.geoLocationManager.d.ts**.|
61|geolocation| interface | CachedGnssLocationsRequest | Migrated to **@ohos.geoLocationManager.d.ts**.|
62|geolocation| interface | GeofenceRequest | Migrated to **@ohos.geoLocationManager.d.ts**.|
63|geolocation| interface | Geofence | Migrated to **@ohos.geoLocationManager.d.ts**.|
64|geolocation| interface | ReverseGeoCodeRequest | Migrated to **@ohos.geoLocationManager.d.ts**.|
65|geolocation| interface | GeoCodeRequest | Migrated to **@ohos.geoLocationManager.d.ts**.|
66|geolocation| interface | GeoAddress | Migrated to **@ohos.geoLocationManager.d.ts**.|
67|geolocation| interface | LocationRequest | Migrated to **@ohos.geoLocationManager.d.ts**.|
68|geolocation| interface | CurrentLocationRequest | Migrated to **@ohos.geoLocationManager.d.ts**.|
69|geolocation| interface | Location | Migrated to **@ohos.geoLocationManager.d.ts**.|
70|geolocation| enum | LocationRequestPriority | Migrated to **@ohos.geoLocationManager.d.ts**.|
71|geolocation| enum | LocationRequestScenario | Migrated to **@ohos.geoLocationManager.d.ts**.|
72|geolocation| enum | GeoLocationErrorCode | Deprecated.|
73|geolocation| enum | LocationPrivacyType | Migrated to **@ohos.geoLocationManager.d.ts**.|
74|geolocation| enum | LocationCommand | Migrated to **@ohos.geoLocationManager.d.ts**.|
75
76
77**(Optional) Adaptation Guide**
78
79The following sample code shows how to call **enableLocation** in the new version:
80
81  ```ts
82  import geoLocationManager from '@ohos.geoLocationManager';
83  try {
84      geoLocationManager.enableLocation((err, data) => {
85          if (err) {
86              console.log('enableLocation: err=' + JSON.stringify(err));
87          }
88      });
89  } catch (err) {
90      console.error("errCode:" + err.code + ",errMessage:" + err.message);
91  }
92  ```
93