harmony 鸿蒙位置服务子系统ChangeLog

  • 2023-06-24
  • 浏览 (374)

位置服务子系统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’;

关键的接口/组件变更

|类名|接口类型|接口声明|变更类型| | –|–|–|–| |Geolocation|class|Geolocation|接口迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager代替| |Geolocation|interface|static getLocation(options?: GetLocationOption): void;|接口迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager.getCurrentLocation代替| |Geolocation|interface|static getLocationType(options?: GetLocationTypeOption): void;|接口废弃| |Geolocation|interface|static subscribe(options: SubscribeLocationOption): void;| 接口迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager.on#event:locationChange代替| |Geolocation|interface|static unsubscribe(): void;| 接口迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager.off#event:locationChange代替| |Geolocation|interface|static getSupportedCoordTypes(): Array;| 接口废弃| ||interface|GeolocationResponse|迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager.Location代替| ||interface|GetLocationOption|接口迁移到@ohos.geoLocationManager.d.ts,使用ohos.geoLocationManager/geoLocationManager.CurrentLocationRequest代替| ||interface|GetLocationTypeResponse|接口废弃| ||interface|GetLocationTypeOption|接口废弃| ||interface|SubscribeLocationOption|接口迁移到@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

0  赞