• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Location Subsystem Changelog
2
3## cl.location.1 API Migration from @system.geolocation.d.ts to @ohos.geoLocationManager.d.ts
4
5APIs in **@system.geolocation.d.ts** do not support throwing error codes. To support this function, all APIs in **@system.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| class | Geolocation | Migrated to **@ohos.geoLocationManager.d.ts** and replaced by **ohos.geoLocationManager/geoLocationManager**.|
23|Geolocation| interface | static getLocation(options?: GetLocationOption): void; | Migrated to **@ohos.geoLocationManager.d.ts** and replaced by **ohos.geoLocationManager/geoLocationManager.getCurrentLocation**.|
24|Geolocation| interface | static getLocationType(options?: GetLocationTypeOption): void; | Deprecated.|
25|Geolocation| interface | static subscribe(options: SubscribeLocationOption): void; |  Migrated to **@ohos.geoLocationManager.d.ts** and replaced by **ohos.geoLocationManager/geoLocationManager.on#event:locationChange**.|
26|Geolocation| interface | static unsubscribe(): void; |  Migrated to **@ohos.geoLocationManager.d.ts** and replaced by **ohos.geoLocationManager/geoLocationManager.off#event:locationChange**.|
27|Geolocation| interface | static getSupportedCoordTypes(): Array<string>; |  Deprecated.|
28|| interface | GeolocationResponse| Migrated to **@ohos.geoLocationManager.d.ts** and replaced by **ohos.geoLocationManager/geoLocationManager.Location**.|
29|| interface | GetLocationOption | Migrated to **@ohos.geoLocationManager.d.ts** and replaced by **ohos.geoLocationManager/geoLocationManager.CurrentLocationRequest**.|
30|| interface | GetLocationTypeResponse | Deprecated.|
31|| interface | GetLocationTypeOption | Deprecated.|
32|| interface | SubscribeLocationOption | Migrated to **@ohos.geoLocationManager.d.ts** and replaced by **ohos.geoLocationManager/geoLocationManager.LocationRequest**.|
33
34
35**(Optional) Adaptation Guide**
36
37The following sample code shows how to call **enableLocation** in the new version:
38
39  ```ts
40  import geoLocationManager from '@ohos.geoLocationManager';
41  try {
42      geoLocationManager.enableLocation((err, data) => {
43          if (err) {
44              console.log('enableLocation: err=' + JSON.stringify(err));
45          }
46      });
47  } catch (err) {
48      console.error("errCode:" + err.code + ",errMessage:" + err.message);
49  }
50  ```
51