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| method | function on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.| 23|geolocation| method | function off(type: 'locationChange', callback?: Callback<Location>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.| 24|geolocation| method | function on(type: 'locationServiceState', callback: Callback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed **type: 'locationServiceState'** to **type: 'locationEnabledChange'**.| 25|geolocation| method | function off(type: 'locationServiceState', callback?: Callback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed **type: 'locationServiceState'** to **type: 'locationEnabledChange'**.| 26|geolocation| method | function on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback<Array<Location>>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed **type: 'cachedGnssLocationsReporting'** to **type: 'cachedGnssLocationsChange'**.| 27|geolocation| method | function off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed **type: 'cachedGnssLocationsReporting'** to **type: 'cachedGnssLocationsChange'**.| 28|geolocation| method | function on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed **type: 'gnssStatusChange'** to **type: 'satelliteStatusChange'**.| 29|geolocation| method | function off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed **type: 'gnssStatusChange'** to **type: 'satelliteStatusChange'**.| 30|geolocation| method | function on(type: 'nmeaMessageChange', callback: Callback<string>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed **type: 'nmeaMessageChange'** to **type: 'nmeaMessage'**.| 31|geolocation| method | function off(type: 'nmeaMessageChange', callback?: Callback<string>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed **type: 'nmeaMessageChange'** to **type: 'nmeaMessage'**.| 32|geolocation| method | function on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed **type: 'fenceStatusChange'** to **type: 'gnssFenceStatusChange'**.| 33|geolocation| method | function off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed **type: 'fenceStatusChange'** to **type: 'gnssFenceStatusChange'**.| 34|geolocation| method | function getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.| 35|geolocation| method | function getCurrentLocation(callback: AsyncCallback<Location>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.| 36|geolocation| method | function getCurrentLocation(request?: CurrentLocationRequest): Promise<Location>; | Migrated to **@ohos.geoLocationManager.d.ts**.| 37|geolocation| method | function getLastLocation(callback: AsyncCallback<Location>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function getLastLocation(): Location**.| 38|geolocation| method | function getLastLocation(): Promise<Location>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function getLastLocation(): Location**.| 39|geolocation| method | function isLocationEnabled(callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function isLocationEnabled(): boolean**.| 40|geolocation| method | function isLocationEnabled(): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function isLocationEnabled(): boolean**.| 41|geolocation| method | function requestEnableLocation(callback: AsyncCallback<boolean>): void; | Deleted.| 42|geolocation| method | function requestEnableLocation(): Promise<boolean>; | Deleted.| 43|geolocation| method | function enableLocation(callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.| 44|geolocation| method | function enableLocation(): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts**.| 45|geolocation| method | function disableLocation(callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function disableLocation(): void**.| 46|geolocation| method | function disableLocation(): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function disableLocation(): void**.| 47|geolocation| method | function getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.| 48|geolocation| method | function getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<GeoAddress>>; | Migrated to **@ohos.geoLocationManager.d.ts**.| 49|geolocation| method | function getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.| 50|geolocation| method | function getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAddress>>; | Migrated to **@ohos.geoLocationManager.d.ts**.| 51|geolocation| method | function isGeoServiceAvailable(callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function isGeocoderAvailable(): boolean**.| 52|geolocation| method | function isGeoServiceAvailable(): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function isGeocoderAvailable(): boolean**.| 53|geolocation| method | function getCachedGnssLocationsSize(callback: AsyncCallback<number>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.| 54|geolocation| method | function getCachedGnssLocationsSize(): Promise<number>; | Migrated to **@ohos.geoLocationManager.d.ts**.| 55|geolocation| method | function flushCachedGnssLocations(callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.| 56|geolocation| method | function flushCachedGnssLocations(): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts**.| 57|geolocation| method | function sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts**.| 58|geolocation| method | function sendCommand(command: LocationCommand): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts**.| 59|geolocation| method | function enableLocationMock(callback: AsyncCallback<void>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function enableLocationMock(): void**.| 60|geolocation| method | function enableLocationMock(): Promise<void>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function enableLocationMock(): void**.| 61|geolocation| method | function disableLocationMock(callback: AsyncCallback<void>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function disableLocationMock(): void**.| 62|geolocation| method | function disableLocationMock(): Promise<void>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function disableLocationMock(): void**.| 63|geolocation| method | function setMockedLocations(config: LocationMockConfig, callback: AsyncCallback<void>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function setMockedLocations(config: LocationMockConfig): void**.| 64|geolocation| method | function setMockedLocations(config: LocationMockConfig): Promise<void>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function setMockedLocations(config: LocationMockConfig): void**.| 65|geolocation| method | function enableReverseGeocodingMock(callback: AsyncCallback<void>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function enableReverseGeocodingMock(): void**.| 66|geolocation| method | function enableReverseGeocodingMock(): Promise<void>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function enableReverseGeocodingMock(): void**.| 67|geolocation| method | function disableReverseGeocodingMock(callback: AsyncCallback<void>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function disableReverseGeocodingMock(): void**.| 68|geolocation| method | function disableReverseGeocodingMock(): Promise<void>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function disableReverseGeocodingMock(): void**.| 69|geolocation| method | function setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>, callback: AsyncCallback<void>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>): void**.| 70|geolocation| method | function setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>): Promise<void>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>): void**.| 71|geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType, callback: AsyncCallback<boolean>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function isLocationPrivacyConfirmed(type: LocationPrivacyType): boolean**.| 72|geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType,): Promise<boolean>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function isLocationPrivacyConfirmed(type: LocationPrivacyType): boolean**.| 73|geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback<void>): void; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): void**.| 74|geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): Promise<void>; | Migrated to **@ohos.geoLocationManager.d.ts** and changed to **function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): void**.| 75|geolocation| interface | SatelliteStatusInfo | Migrated to **@ohos.geoLocationManager.d.ts**.| 76|geolocation| interface | CachedGnssLocationsRequest | Migrated to **@ohos.geoLocationManager.d.ts**.| 77|geolocation| interface | GeofenceRequest | Migrated to **@ohos.geoLocationManager.d.ts**.| 78|geolocation| interface | Geofence | Migrated to **@ohos.geoLocationManager.d.ts**.| 79|geolocation| interface | ReverseGeoCodeRequest | Migrated to **@ohos.geoLocationManager.d.ts**.| 80|geolocation| interface | GeoCodeRequest | Migrated to **@ohos.geoLocationManager.d.ts**.| 81|geolocation| interface | GeoAddress | Migrated to **@ohos.geoLocationManager.d.ts**.| 82|geolocation| interface | LocationRequest | Migrated to **@ohos.geoLocationManager.d.ts**.| 83|geolocation| interface | CurrentLocationRequest | Migrated to **@ohos.geoLocationManager.d.ts**.| 84|geolocation| interface | Location | Migrated to **@ohos.geoLocationManager.d.ts**.| 85|geolocation| enum | LocationRequestPriority | Migrated to **@ohos.geoLocationManager.d.ts**.| 86|geolocation| enum | LocationRequestScenario | Migrated to **@ohos.geoLocationManager.d.ts**.| 87|geolocation| enum | GeoLocationErrorCode | Deprecated.| 88|geolocation| enum | LocationPrivacyType | Migrated to **@ohos.geoLocationManager.d.ts**.| 89|geolocation| enum | LocationCommand | Migrated to **@ohos.geoLocationManager.d.ts**.| 90 91 92**(Optional) Adaptation Guide** 93 94The following sample code shows how to call **enableLocation** in the new version: 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 ``` 108