openharmony 鸿蒙 changelogs-system-geolocation

2023-06-24 浏览 (476)

Location Subsystem Changelog

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

APIs in @system.geolocation.d.ts do not support throwing error codes. To support this function, all APIs in @system.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 Impact

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
GeolocationclassGeolocationMigrated to @ohos.geoLocationManager.d.ts and replaced by ohos.geoLocationManager/geoLocationManager.
Geolocationinterfacestatic getLocation(options?: GetLocationOption): void;Migrated to @ohos.geoLocationManager.d.ts and replaced by ohos.geoLocationManager/geoLocationManager.getCurrentLocation.
Geolocationinterfacestatic getLocationType(options?: GetLocationTypeOption): void;Deprecated.
Geolocationinterfacestatic subscribe(options: SubscribeLocationOption): void;Migrated to @ohos.geoLocationManager.d.ts and replaced by ohos.geoLocationManager/geoLocationManager.on#event:locationChange.
Geolocationinterfacestatic unsubscribe(): void;Migrated to @ohos.geoLocationManager.d.ts and replaced by ohos.geoLocationManager/geoLocationManager.off#event:locationChange.
Geolocationinterfacestatic getSupportedCoordTypes(): Array;Deprecated.
interfaceGeolocationResponseMigrated to @ohos.geoLocationManager.d.ts and replaced by ohos.geoLocationManager/geoLocationManager.Location.
interfaceGetLocationOptionMigrated to @ohos.geoLocationManager.d.ts and replaced by ohos.geoLocationManager/geoLocationManager.CurrentLocationRequest.
interfaceGetLocationTypeResponseDeprecated.
interfaceGetLocationTypeOptionDeprecated.
interfaceSubscribeLocationOptionMigrated to @ohos.geoLocationManager.d.ts and replaced by ohos.geoLocationManager/geoLocationManager.LocationRequest.

(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 鸿蒙Readme

harmony 鸿蒙Example Subsystem Changelog

harmony 鸿蒙Ability Framework Changelog

harmony 鸿蒙Account Subsystem Changelog

harmony 鸿蒙ArkUI Subsystem ChangeLog

harmony 鸿蒙Multimedia Subsystem Changelog

harmony 鸿蒙Common Library Subsystem Changelog

harmony 鸿蒙Distributed Data Management Subsystem JS API Changelog

harmony 鸿蒙File Management Subsystem Changelog

harmony 鸿蒙Input Method Framework ChangeLog

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