openharmony 鸿蒙 changelogs-system-geolocation

2023-06-24 浏览 (851)

位置服务子系统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 鸿蒙Readme

harmony 鸿蒙xxx子系统ChangeLog

harmony 鸿蒙元能力子系统JS API变更Changelog

harmony 鸿蒙帐号子系统changeLog

harmony 鸿蒙arkui子系统ChangeLog

harmony 鸿蒙媒体子系统 JS API 变更 Changelog

harmony 鸿蒙公共基础类库子系统JS API变更Changelog

harmony 鸿蒙分布式数据管理子系统JS API变更Changelog

harmony 鸿蒙文件管理子系统ChangeLog

harmony 鸿蒙输入法框架changeLog

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