openharmony 鸿蒙 changelogs-ohos-geoLocationManager

2023-02-17 浏览 (633)

Location Subsystem ChangeLog

cl.location.1 API Migration from @ohos.geolocation.d.ts to @ohos.geoLocationManager.d.ts

APIs 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.

To use APIs of the location subsystem, you need to import @ohos.geoLocationManager.

import geoLocationManager from '@ohos.geoLocationManager';

Change Impacts

All APIs of the location subsystem are affected. To ensure normal use of these APIs, you need to import @ohos.geoLocationManager.

import geoLocationManager from '@ohos.geoLocationManager';

Key API/Component Changes

ClassAPI TypeDeclarationChange Type
geolocationmethodfunction on(type: 'locationChange', request: LocationRequest, callback: Callback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction off(type: 'locationChange', callback?: Callback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction on(type: 'locationServiceState', callback: Callback): void;Migrated to @ohos.geoLocationManager.d.ts and changed type: 'locationServiceState' to type: 'locationEnabledChange'.
geolocationmethodfunction off(type: 'locationServiceState', callback?: Callback): void;Migrated to @ohos.geoLocationManager.d.ts and changed type: 'locationServiceState' to type: 'locationEnabledChange'.
geolocationmethodfunction on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback<Array>): void;Migrated to @ohos.geoLocationManager.d.ts and changed type: 'cachedGnssLocationsReporting' to type: 'cachedGnssLocationsChange'.
geolocationmethodfunction off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array>): void;Migrated to @ohos.geoLocationManager.d.ts and changed type: 'cachedGnssLocationsReporting' to type: 'cachedGnssLocationsChange'.
geolocationmethodfunction on(type: 'gnssStatusChange', callback: Callback): void;Migrated to @ohos.geoLocationManager.d.ts and changed type: 'gnssStatusChange' to type: 'satelliteStatusChange'.
geolocationmethodfunction off(type: 'gnssStatusChange', callback?: Callback): void;Migrated to @ohos.geoLocationManager.d.ts and changed type: 'gnssStatusChange' to type: 'satelliteStatusChange'.
geolocationmethodfunction on(type: 'nmeaMessageChange', callback: Callback): void;Migrated to @ohos.geoLocationManager.d.ts and changed type: 'nmeaMessageChange' to type: 'nmeaMessage'.
geolocationmethodfunction off(type: 'nmeaMessageChange', callback?: Callback): void;Migrated to @ohos.geoLocationManager.d.ts and changed type: 'nmeaMessageChange' to type: 'nmeaMessage'.
geolocationmethodfunction on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;Migrated to @ohos.geoLocationManager.d.ts and changed type: 'fenceStatusChange' to type: 'gnssFenceStatusChange'.
geolocationmethodfunction off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;Migrated to @ohos.geoLocationManager.d.ts and changed type: 'fenceStatusChange' to type: 'gnssFenceStatusChange'.
geolocationmethodfunction getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction getCurrentLocation(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction getCurrentLocation(request?: CurrentLocationRequest): Promise;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction getLastLocation(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function getLastLocation(): Location.
geolocationmethodfunction getLastLocation(): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function getLastLocation(): Location.
geolocationmethodfunction isLocationEnabled(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function isLocationEnabled(): boolean.
geolocationmethodfunction isLocationEnabled(): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function isLocationEnabled(): boolean.
geolocationmethodfunction requestEnableLocation(callback: AsyncCallback): void;Deleted.
geolocationmethodfunction requestEnableLocation(): Promise;Deleted.
geolocationmethodfunction enableLocation(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction enableLocation(): Promise;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction disableLocation(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function disableLocation(): void.
geolocationmethodfunction disableLocation(): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function disableLocation(): void.
geolocationmethodfunction getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array>): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array>;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<Array>): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array>;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction isGeoServiceAvailable(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function isGeocoderAvailable(): boolean.
geolocationmethodfunction isGeoServiceAvailable(): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function isGeocoderAvailable(): boolean.
geolocationmethodfunction getCachedGnssLocationsSize(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction getCachedGnssLocationsSize(): Promise;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction flushCachedGnssLocations(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction flushCachedGnssLocations(): Promise;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction sendCommand(command: LocationCommand, callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction sendCommand(command: LocationCommand): Promise;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction enableLocationMock(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function enableLocationMock(): void.
geolocationmethodfunction enableLocationMock(): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function enableLocationMock(): void.
geolocationmethodfunction disableLocationMock(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function disableLocationMock(): void.
geolocationmethodfunction disableLocationMock(): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function disableLocationMock(): void.
geolocationmethodfunction setMockedLocations(config: LocationMockConfig, callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function setMockedLocations(config: LocationMockConfig): void.
geolocationmethodfunction setMockedLocations(config: LocationMockConfig): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function setMockedLocations(config: LocationMockConfig): void.
geolocationmethodfunction enableReverseGeocodingMock(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function enableReverseGeocodingMock(): void.
geolocationmethodfunction enableReverseGeocodingMock(): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function enableReverseGeocodingMock(): void.
geolocationmethodfunction disableReverseGeocodingMock(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function disableReverseGeocodingMock(): void.
geolocationmethodfunction disableReverseGeocodingMock(): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function disableReverseGeocodingMock(): void.
geolocationmethodfunction setReverseGeocodingMockInfo(mockInfos: Array, callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function setReverseGeocodingMockInfo(mockInfos: Array): void.
geolocationmethodfunction setReverseGeocodingMockInfo(mockInfos: Array): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function setReverseGeocodingMockInfo(mockInfos: Array): void.
geolocationmethodfunction isLocationPrivacyConfirmed(type: LocationPrivacyType, callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function isLocationPrivacyConfirmed(type: LocationPrivacyType): boolean.
geolocationmethodfunction isLocationPrivacyConfirmed(type: LocationPrivacyType,): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function isLocationPrivacyConfirmed(type: LocationPrivacyType): boolean.
geolocationmethodfunction setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts and changed to function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): void.
geolocationmethodfunction setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): Promise;Migrated to @ohos.geoLocationManager.d.ts and changed to function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): void.
geolocationinterfaceSatelliteStatusInfoMigrated to @ohos.geoLocationManager.d.ts.
geolocationinterfaceCachedGnssLocationsRequestMigrated to @ohos.geoLocationManager.d.ts.
geolocationinterfaceGeofenceRequestMigrated to @ohos.geoLocationManager.d.ts.
geolocationinterfaceGeofenceMigrated to @ohos.geoLocationManager.d.ts.
geolocationinterfaceReverseGeoCodeRequestMigrated to @ohos.geoLocationManager.d.ts.
geolocationinterfaceGeoCodeRequestMigrated to @ohos.geoLocationManager.d.ts.
geolocationinterfaceGeoAddressMigrated to @ohos.geoLocationManager.d.ts.
geolocationinterfaceLocationRequestMigrated to @ohos.geoLocationManager.d.ts.
geolocationinterfaceCurrentLocationRequestMigrated to @ohos.geoLocationManager.d.ts.
geolocationinterfaceLocationMigrated to @ohos.geoLocationManager.d.ts.
geolocationenumLocationRequestPriorityMigrated to @ohos.geoLocationManager.d.ts.
geolocationenumLocationRequestScenarioMigrated to @ohos.geoLocationManager.d.ts.
geolocationenumGeoLocationErrorCodeDeprecated.
geolocationenumLocationPrivacyTypeMigrated to @ohos.geoLocationManager.d.ts.
geolocationenumLocationCommandMigrated to @ohos.geoLocationManager.d.ts.

(Optional) Adaptation Guide

The following sample code shows how to call enableLocation in the new version:

import geoLocationManager from '@ohos.geoLocationManager';
try {
    geoLocationManager.enableLocation((err, data) => {
        if (err) {
            console.log('enableLocation: err=' + JSON.stringify(err));
        }
    });
} catch (err) {
    console.error("errCode:" + err.code + ",errMessage:" + err.message);
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Resource Scheduler Subsystem ChangeLog

harmony 鸿蒙ArkUI Subsystem ChangeLog

harmony 鸿蒙Bundle Manager Subsystem ChangeLog

harmony 鸿蒙File Management Subsystem Changelog

harmony 鸿蒙Input Method Framework ChangeLog

harmony 鸿蒙Location Subsystem ChangeLog

harmony 鸿蒙Location Subsystem ChangeLog

harmony 鸿蒙User IAM Subsystem ChangeLog

harmony 鸿蒙Window Subsystem ChangeLog

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/35fae4071df345af91ba58172e3754df