• 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| method | function on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
23|geolocation| method | function off(type: 'locationChange', callback?: Callback<Location>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
24|geolocation| method | function on(type: 'locationServiceState', callback: Callback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,type: 'locationServiceState'更改为type: 'locationEnabledChange' |
25|geolocation| method | function off(type: 'locationServiceState', callback?: Callback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,type: 'locationServiceState'更改为type: 'locationEnabledChange' |
26|geolocation| method | function on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback<Array<Location>>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,type: 'cachedGnssLocationsReporting'更改为type: 'cachedGnssLocationsChange' |
27|geolocation| method | function off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,type: 'cachedGnssLocationsReporting'更改为type: 'cachedGnssLocationsChange' |
28|geolocation| method | function on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,type: 'gnssStatusChange'更改为type: 'satelliteStatusChange' |
29|geolocation| method | function off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,type: 'gnssStatusChange'更改为type: 'satelliteStatusChange' |
30|geolocation| method | function on(type: 'nmeaMessageChange', callback: Callback<string>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,type: 'nmeaMessageChange'更改为type: 'nmeaMessage' |
31|geolocation| method | function off(type: 'nmeaMessageChange', callback?: Callback<string>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,type: 'nmeaMessageChange'更改为type: 'nmeaMessage' |
32|geolocation| method | function on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; | 接口迁移到@ohos.geoLocationManager.d.ts,type: 'fenceStatusChange'更改为type: 'gnssFenceStatusChange' |
33|geolocation| method | function off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; | 接口迁移到@ohos.geoLocationManager.d.ts,type: 'fenceStatusChange'更改为type: 'gnssFenceStatusChange' |
34|geolocation| method | function getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
35|geolocation| method | function getCurrentLocation(callback: AsyncCallback<Location>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
36|geolocation| method | function getCurrentLocation(request?: CurrentLocationRequest): Promise<Location>; | 接口迁移到@ohos.geoLocationManager.d.ts |
37|geolocation| method | function getLastLocation(callback: AsyncCallback<Location>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function getLastLocation(): Location; |
38|geolocation| method | function getLastLocation(): Promise<Location>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function getLastLocation(): Location; |
39|geolocation| method | function isLocationEnabled(callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function isLocationEnabled(): boolean; |
40|geolocation| method | function isLocationEnabled(): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function isLocationEnabled(): boolean; |
41|geolocation| method | function requestEnableLocation(callback: AsyncCallback<boolean>): void; | 接口删除 |
42|geolocation| method | function requestEnableLocation(): Promise<boolean>; | 接口删除 |
43|geolocation| method | function enableLocation(callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
44|geolocation| method | function enableLocation(): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts |
45|geolocation| method | function disableLocation(callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function disableLocation(): void; |
46|geolocation| method | function disableLocation(): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function disableLocation(): void; |
47|geolocation| method | function getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
48|geolocation| method | function getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<GeoAddress>>; | 接口迁移到@ohos.geoLocationManager.d.ts |
49|geolocation| method | function getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
50|geolocation| method | function getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAddress>>; | 接口迁移到@ohos.geoLocationManager.d.ts |
51|geolocation| method | function isGeoServiceAvailable(callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function isGeocoderAvailable(): boolean; |
52|geolocation| method | function isGeoServiceAvailable(): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function isGeocoderAvailable(): boolean; |
53|geolocation| method | function getCachedGnssLocationsSize(callback: AsyncCallback<number>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
54|geolocation| method | function getCachedGnssLocationsSize(): Promise<number>; | 接口迁移到@ohos.geoLocationManager.d.ts |
55|geolocation| method | function flushCachedGnssLocations(callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
56|geolocation| method | function flushCachedGnssLocations(): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts |
57|geolocation| method | function sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts |
58|geolocation| method | function sendCommand(command: LocationCommand): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts |
59|geolocation| method | function enableLocationMock(callback: AsyncCallback<void>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function enableLocationMock(): void; |
60|geolocation| method | function enableLocationMock(): Promise<void>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function enableLocationMock(): void; |
61|geolocation| method | function disableLocationMock(callback: AsyncCallback<void>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function disableLocationMock(): void; |
62|geolocation| method | function disableLocationMock(): Promise<void>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function disableLocationMock(): void; |
63|geolocation| method | function setMockedLocations(config: LocationMockConfig, callback: AsyncCallback<void>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function setMockedLocations(config: LocationMockConfig): void; |
64|geolocation| method | function setMockedLocations(config: LocationMockConfig): Promise<void>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function setMockedLocations(config: LocationMockConfig): void; |
65|geolocation| method | function enableReverseGeocodingMock(callback: AsyncCallback<void>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function enableReverseGeocodingMock(): void; |
66|geolocation| method | function enableReverseGeocodingMock(): Promise<void>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function enableReverseGeocodingMock(): void; |
67|geolocation| method | function disableReverseGeocodingMock(callback: AsyncCallback<void>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function disableReverseGeocodingMock(): void; |
68|geolocation| method | function disableReverseGeocodingMock(): Promise<void>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function disableReverseGeocodingMock(): void; |
69|geolocation| method | function setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>, callback: AsyncCallback<void>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>): void; |
70|geolocation| method | function setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>): Promise<void>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>): void; |
71|geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType, callback: AsyncCallback<boolean>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function isLocationPrivacyConfirmed(type: LocationPrivacyType): boolean; |
72|geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType,): Promise<boolean>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function isLocationPrivacyConfirmed(type: LocationPrivacyType): boolean; |
73|geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback<void>): void; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): void; |
74|geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): Promise<void>; | 接口迁移到@ohos.geoLocationManager.d.ts,更改为function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): void; |
75|geolocation| interface | SatelliteStatusInfo | 接口迁移到@ohos.geoLocationManager.d.ts |
76|geolocation| interface | CachedGnssLocationsRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
77|geolocation| interface | GeofenceRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
78|geolocation| interface | Geofence | 接口迁移到@ohos.geoLocationManager.d.ts |
79|geolocation| interface | ReverseGeoCodeRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
80|geolocation| interface | GeoCodeRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
81|geolocation| interface | GeoAddress | 接口迁移到@ohos.geoLocationManager.d.ts |
82|geolocation| interface | LocationRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
83|geolocation| interface | CurrentLocationRequest | 接口迁移到@ohos.geoLocationManager.d.ts |
84|geolocation| interface | Location | 接口迁移到@ohos.geoLocationManager.d.ts |
85|geolocation| enum | LocationRequestPriority | 接口迁移到@ohos.geoLocationManager.d.ts |
86|geolocation| enum | LocationRequestScenario | 接口迁移到@ohos.geoLocationManager.d.ts |
87|geolocation| enum | GeoLocationErrorCode | 接口废弃 |
88|geolocation| enum | LocationPrivacyType | 接口迁移到@ohos.geoLocationManager.d.ts |
89|geolocation| enum | LocationCommand | 接口迁移到@ohos.geoLocationManager.d.ts |
90
91
92**适配指导(可选,不涉及则可以删除)**
93
94以enableLocation为例,在新版本上需要使用如下方式进行调用:
95
96  ```ts
97  import geoLocationManager from '@ohos.geoLocationManager';
98  try {
99      geoLocationManager.enableLocation((err, data) => {
100          if (err) {
101              console.log('enableLocation: err=' + JSON.stringify(err));
102          }
103      });
104  } catch (err) {
105      console.error("errCode:" + err.code + ",errMessage:" + err.message);
106  }
107  ```