openharmony 鸿蒙 changelogs-system-geolocation

2023-02-03 浏览 (633)

位置服务子系统ChangeLog

cl.location.1 @system.geolocation.d.ts接口迁移到新增的@ohos.geoLocationManager.d.ts

@system.geolocation.d.ts接口不支持抛出错误码,为了支持错误码功能,把@system.geolocation.d.ts中所有接口,迁移到新增的@ohos.geoLocationManager.d.ts中,并增加错误码描述。

后续需要import @ohos.geoLocationManager才能使用位置服务的接口:

import geoLocationManager from '@ohos.geoLocationManager';

变更影响

对位置服务所有接口的使用有影响,需要import @ohos.geoLocationManager才能使用位置服务接口:

import geoLocationManager from '@ohos.geoLocationManager';

关键的接口/组件变更

类名接口类型接口声明变更类型
GeolocationclassGeolocation接口迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager代替
Geolocationinterfacestatic getLocation(options?: GetLocationOption): void;接口迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager.getCurrentLocation代替
Geolocationinterfacestatic getLocationType(options?: GetLocationTypeOption): void;接口废弃
Geolocationinterfacestatic subscribe(options: SubscribeLocationOption): void;接口迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager.on#event:locationChange代替
Geolocationinterfacestatic unsubscribe(): void;接口迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager.off#event:locationChange代替
Geolocationinterfacestatic getSupportedCoordTypes(): Array;接口废弃
interfaceGeolocationResponse迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager.Location代替
interfaceGetLocationOption接口迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager.CurrentLocationRequest代替
interfaceGetLocationTypeResponse接口废弃
interfaceGetLocationTypeOption接口废弃
interfaceSubscribeLocationOption接口迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager.LocationRequest代替

适配指导(可选,不涉及则可以删除)

以enableLocation为例,在新版本上需要使用如下方式进行调用:

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 鸿蒙资源调度子系统ChangeLog

harmony 鸿蒙arkui子系统ChangeLog

harmony 鸿蒙包管理子系统ChangeLog

harmony 鸿蒙文件管理子系统ChangeLog

harmony 鸿蒙输入法框架changeLog

harmony 鸿蒙位置服务子系统ChangeLog

harmony 鸿蒙位置服务子系统ChangeLog

harmony 鸿蒙用户IAM子系统Changelog

harmony 鸿蒙窗口子系统ChangeLog

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