• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 位置服务子系统ChangeLog
2
3## cl.location.1 @ohos.geolocation.d.ts接口迁移到新增的@ohos.geoLocationManager.d.ts
4
5@ohos.geolocation.d.ts接口不支持抛出错误码,为了支持错误码功能,把@ohos.geolocation.d.ts中所有接口,迁移到新增的@ohos.geoLocationManager.d.ts中,并增加错误码描述。
6
7后续需要import @ohos.geoLocationManager才能使用位置服务的接口:
8
9import geoLocationManager from '@ohos.geoLocationManager';
10
11
12**变更影响**
13
14对位置服务所有接口的使用有影响,需要import @ohos.geoLocationManager才能使用位置服务接口:
15
16import geoLocationManager from '@ohos.geoLocationManager';
17
18**关键的接口/组件变更**
19
20| 类名 | 接口类型 | 接口声明 | 变更类型 |
21|  -- | -- | -- | -- |
22|geolocation| namespace | declare namespace geolocation| 迁移到@ohos.geoLocationManager.d.ts,使用namespace geoLocationManager代替 |
23|geolocation| method | function on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
24|geolocation| method | function off(type: 'locationChange', callback?: Callback<Location>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
25|geolocation| method | function on(type: 'locationServiceState', callback: Callback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
26|geolocation| method | function off(type: 'locationServiceState', callback?: Callback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
27|geolocation| method | function on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback<Array<Location>>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
28|geolocation| method | function off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
29|geolocation| method | function on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
30|geolocation| method | function off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
31|geolocation| method | function on(type: 'nmeaMessageChange', callback: Callback<string>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
32|geolocation| method | function off(type: 'nmeaMessageChange', callback?: Callback<string>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
33|geolocation| method | function on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
34|geolocation| method | function off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
35|geolocation| method | function getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
36|geolocation| method | function getCurrentLocation(callback: AsyncCallback<Location>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
37|geolocation| method | function getCurrentLocation(request?: CurrentLocationRequest): Promise<Location>; | 接口迁移到@ohos.geoLocationManager.d.ts |
38|geolocation| method | function getLastLocation(callback: AsyncCallback<Location>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
39|geolocation| method | function getLastLocation(): Promise<Location>; | 接口迁移到@ohos.geoLocationManager.d.ts |
40|geolocation| method | function isLocationEnabled(callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
41|geolocation| method | function isLocationEnabled(): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts |
42|geolocation| method | function requestEnableLocation(callback: AsyncCallback<boolean>): void; | 接口删除 |
43|geolocation| method | function requestEnableLocation(): Promise<boolean>; | 接口删除 |
44|geolocation| method | function enableLocation(callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
45|geolocation| method | function enableLocation(): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts |
46|geolocation| method | function disableLocation(callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
47|geolocation| method | function disableLocation(): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts |
48|geolocation| method | function getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
49|geolocation| method | function getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<GeoAddress>>; | 接口迁移到@ohos.geoLocationManager.d.ts |
50|geolocation| method | function getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
51|geolocation| method | function getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAddress>>; | 接口迁移到@ohos.geoLocationManager.d.ts |
52|geolocation| method | function isGeoServiceAvailable(callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
53|geolocation| method | function isGeoServiceAvailable(): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts |
54|geolocation| method | function getCachedGnssLocationsSize(callback: AsyncCallback<number>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
55|geolocation| method | function getCachedGnssLocationsSize(): Promise<number>; | 接口迁移到@ohos.geoLocationManager.d.ts |
56|geolocation| method | function flushCachedGnssLocations(callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
57|geolocation| method | function flushCachedGnssLocations(): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts |
58|geolocation| method | function sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
59|geolocation| method | function sendCommand(command: LocationCommand): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts |
60|geolocation| interface | SatelliteStatusInfo | 接口迁移到@ohos.geoLocationManager.d.ts |
61|geolocation| interface | CachedGnssLocationsRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
62|geolocation| interface | GeofenceRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
63|geolocation| interface | Geofence | 接口迁移到@ohos.geoLocationManager.d.ts |
64|geolocation| interface | ReverseGeoCodeRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
65|geolocation| interface | GeoCodeRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
66|geolocation| interface | GeoAddress | 接口迁移到@ohos.geoLocationManager.d.ts |
67|geolocation| interface | LocationRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
68|geolocation| interface | CurrentLocationRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
69|geolocation| interface | Location | 接口迁移到@ohos.geoLocationManager.d.ts |
70|geolocation| enum | LocationRequestPriority | 接口迁移到@ohos.geoLocationManager.d.ts |
71|geolocation| enum | LocationRequestScenario | 接口迁移到@ohos.geoLocationManager.d.ts |
72|geolocation| enum | GeoLocationErrorCode | 接口废弃 |
73|geolocation| enum | LocationPrivacyType | 接口迁移到@ohos.geoLocationManager.d.ts |
74|geolocation| enum | LocationCommand | 接口迁移到@ohos.geoLocationManager.d.ts |
75
76
77**适配指导(可选,不涉及则可以删除)**
78
79以enableLocation为例,在新版本上需要使用如下方式进行调用:
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  ```