openharmony 鸿蒙 changelogs-ohos-geolocation

2023-02-17 浏览 (581)

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
geolocationnamespacedeclare namespace geolocationMigrated to @ohos.geoLocationManager.d.ts and replaced by namespace geoLocationManager.
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.
geolocationmethodfunction off(type: 'locationServiceState', callback?: Callback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, callback: Callback<Array>): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array>): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction on(type: 'gnssStatusChange', callback: Callback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction off(type: 'gnssStatusChange', callback?: Callback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction on(type: 'nmeaMessageChange', callback: Callback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction off(type: 'nmeaMessageChange', callback?: Callback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;Migrated to @ohos.geoLocationManager.d.ts.
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.
geolocationmethodfunction getLastLocation(): Promise;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction isLocationEnabled(callback: AsyncCallback): void;Migrated to @ohos.geoLocationManager.d.ts.
geolocationmethodfunction isLocationEnabled(): Promise;Migrated to @ohos.geoLocationManager.d.ts.
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.
geolocationmethodfunction disableLocation(): Promise;Migrated to @ohos.geoLocationManager.d.ts.
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.
geolocationmethodfunction isGeoServiceAvailable(): Promise;Migrated to @ohos.geoLocationManager.d.ts.
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.
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/b9322c4c7a464d9fa4cbceac8b0ad3a8