女人荫蒂被添全过程13种图片,亚洲+欧美+在线,欧洲精品无码一区二区三区 ,在厨房拨开内裤进入毛片

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

harmony-utils之LocationUtil,定位相關工具類

童長老 ? 來源:jf_14594073 ? 作者:jf_14594073 ? 2025-07-03 18:13 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

harmony-utils之LocationUtil,定位相關工具類

harmony-utils 簡介與說明


harmony-utils 一款功能豐富且極易上手的HarmonyOS工具庫,借助眾多實用工具類,致力于助力開發者迅速構建鴻蒙應用。其封裝的工具涵蓋了APP、設備、屏幕、授權、通知、線程間通信、彈框、吐司、生物認證、用戶首選項、拍照、相冊、掃碼、文件、日志、異常捕獲、字符、字符串、數字、集合、日期、隨機、base64、加密、解密、JSON等一系列的功能和作,能夠滿足各種不同的開發需求。
picker_utils 是harmony-utils拆分出來的一個子庫,包含 PickerUtil、PhotoHelper、ScanUtil。

下載安裝
ohpm i @pura/harmony-utils
ohpm i @pura/picker_utils

//全局初始化方法,在UIAbility的onCreate方法中初始化 AppUtil.init()
 onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
   AppUtil.init(this.context);
 }

API方法與使用


isLocationEnabled 判斷位置服務是否已經使能(定位是否開啟)
let isLocationEnabled = LocationUtil.isLocationEnabled();
 ToastUtil.showToast(`定位是否開啟:${isLocationEnabled}`);
requestLocationPermissions 申請定位權限
LocationUtil.requestLocationPermissions().then((grant) = > {
  if (grant) { //已授權
    ToastUtil.showToast("授權成功");
  } else {
    ToastUtil.showToast("請在設置中開啟定位權限");
    WantUtil.toAppSetting();
  }
});
getCurrentLocationEasy 獲取當前位置
LocationUtil.getCurrentLocationEasy().then((location) = > {
  let locationStr = `當前位置1:n${JSON.stringify(location, null, 2)}nn`;
  LocationUtil.getGeoAddressFromLocation(location.latitude, location.longitude, 2).then((address) = > {
    locationStr = locationStr + `當前位置2:n${JSON.stringify(address, null, 2)}`;
    LogUtil.error(locationStr);
  });
}).catch((err: BusinessError) = > {
  let locationStr = `當前位置~異常信息:n錯誤碼: ${err.code}n錯誤信息:${err.message}`;
  LogUtil.error(locationStr);
});
getCurrentLocation 獲取當前位置
LocationUtil.getCurrentLocation().then((location) = > {
  let locationStr = `當前位置:n${JSON.stringify(location, null, 2)}`;
  LogUtil.error(locationStr);
}).catch((err: BusinessError) = > {
  let locationStr = `當前位置~異常信息:n錯誤碼: ${err.code}n錯誤信息:${err.message}`;
  LogUtil.error(locationStr);
});
getLastLocation 獲取上一次位置
let lastLocation = LocationUtil.getLastLocation();
let locationStr = `當前位置:n${JSON.stringify(lastLocation, null, 2)}`;
LogUtil.error(locationStr);
onLocationChangeEasy 開啟位置變化訂閱,并發起定位請求
private locationCallBack: Callback< geoLocationManager.Location > = (location) = > {
  let addrStr = `位置變化訂閱1:n${JSON.stringify(location, null, 2)}`;
  LogUtil.info(addrStr);
}
LocationUtil.onLocationChangeEasy(locationCallBack);
onLocationChange 開啟位置變化訂閱,并發起定位請求
private locationCallBack: Callback< geoLocationManager.Location > = (location) = > {
  let addrStr = `位置變化訂閱1:n${JSON.stringify(location, null, 2)}`;
  LogUtil.info(addrStr);
}

let locationRequest: geoLocationManager.LocationRequest = {
  'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX, //表示快速獲取位置優先,如果應用希望快速拿到一個位置,可以將優先級設置為該字段。
  'scenario': geoLocationManager.LocationRequestScenario.UNSET, //表示未設置優先級,表示LocationRequestPriority無效。
  'timeInterval': 10, //表示上報位置信息的時間間隔,單位是秒。默認值為1,取值范圍為大于等于0。10秒鐘獲取一下位置
  'distanceInterval': 0, //表示上報位置信息的距離間隔。單位是米,默認值為0,取值范圍為大于等于0。
  'maxAccuracy': 0 //表示精度信息,單位是米。
}; //開啟位置變化訂閱,默認Request參數
LocationUtil.onLocationChange(locationRequest, locationCallBack);
offLocationChange 關閉位置變化訂閱,并刪除對應的定位請求
LocationUtil.offLocationChange();
onLocationError 訂閱持續定位過程中的錯誤碼
LocationUtil.onLocationError((locationError: geoLocationManager.LocationError) = > {
  LogUtil.error("訂閱持續定位過程中的錯誤碼: " + locationError);
  ToastUtil.showToast("訂閱持續定位過程中的錯誤碼: " + locationError);
});
offLocationError 取消訂閱持續定位過程中的錯誤碼
LocationUtil.offLocationError();
 ToastUtil.showToast("取消訂閱成功");
onLocationEnabledChange 訂閱位置服務狀態變化
LocationUtil.onLocationError((locationError: geoLocationManager.LocationError) = > {
  LogUtil.error("訂閱持續定位過程中的錯誤碼: " + locationError);
  ToastUtil.showToast("訂閱持續定位過程中的錯誤碼: " + locationError);
});
offLocationEnabledChange 取消訂閱位置服務狀態變化
LocationUtil.offLocationEnabledChange();
 ToastUtil.showToast("取消訂閱成功");
isGeocoderAvailable 判斷地理編碼與逆地理編碼服務是否可用
let isGeocoderAvailable = LocationUtil.isGeocoderAvailable();
 LogUtil.error(`地理編碼與逆地理編碼服務是否可用:${isGeocoderAvailable}`);
getGeoAddressFromLocationName 地理編碼,將地理描述轉換為具體坐標集合
let locationName: string = '上海市浦東新區'; //上海市浦東新區
let address = await LocationUtil.getGeoAddressFromLocationName(locationName)
  .catch((err: BusinessError) = > {
    return `異常信息:${err.code}  ---  ${err.message}`;
  });
let addrStr = `地理編碼:n${JSON.stringify(address, null, 2)}`;
LogUtil.info(addrStr);
getAddressFromLocationName 地理編碼,將地理描述轉換為具體坐標
let locationName: string = '上海市浦東新區'; //上海市浦東新區
let address = await LocationUtil.getAddressFromLocationName(locationName)
  .catch((err: BusinessError) = > {
    return `異常信息:${err.code}  ---  ${err.message}`;
  });
let addrStr = `地理編碼:n${JSON.stringify(address, null, 2)}`;
LogUtil.info(addrStr);
getGeoAddressFromLocation 逆地理編碼,將坐標轉換為地理描述集合
let latitude: number = 32.26;
let longitude: number = 117.618;
let address = await LocationUtil.getGeoAddressFromLocation(latitude, longitude)
  .catch((err: BusinessError) = > {
    return `異常信息:${err.code}  ---  ${err.message}`;
  });
let addrStr = `逆地理編碼:n${JSON.stringify(address, null, 2)}`;
LogUtil.info(addrStr);
getAddressFromLocation 逆地理編碼,將坐標轉換為地理描述
let latitude: number = 32.2;
let longitude: number = 117.6;
let address = await LocationUtil.getAddressFromLocation(latitude, longitude)
  .catch((err: BusinessError) = > {
    return `異常信息:${err.code}  ---  ${err.message}`;
  });
let addrStr = `逆地理編碼:n${JSON.stringify(address, null, 2)}`;
LogUtil.info(addrStr);
getCountryCode 獲取當前的國家碼
let code = await LocationUtil.getCountryCode();
 ToastUtil.showToast(`當前的國家碼:${code}`);
calculateDistance 計算這兩個點間的直線距離,單位為米
let fromLatLng: mapCommon.LatLng = { latitude: 38, longitude: 118 };
let toLatLng: mapCommon.LatLng = { latitude: 38.5, longitude: 118.5 };
let distance1 = LocationUtil.calculateDistance(fromLatLng, toLatLng);
LogUtil.error(`距離1${distance1}米`);

let distance2 = LocationUtil.calculateDistanceEasy(38, 118, 39, 119);
LogUtil.error(`距離2${distance2}米`);
convertCoordinate 坐標轉換,將WGS84坐標系轉換為GCJ02坐標系
let latLng: mapCommon.LatLng = { latitude: 31.8462, longitude: 117.2456 };
let latLng1 = LocationUtil.convertCoordinateSync(mapCommon.CoordinateType.WGS84, mapCommon.CoordinateType.GCJ02, latLng);
LogUtil.error(`坐標轉換,latLng1${JSON.stringify(latLng1, null, 2)}`);
let latLng2 = LocationUtil.convertCoordinateEasy(latLng);
LogUtil.error(`坐標轉換,latLng2${JSON.stringify(latLng2, null, 2)}`);

創作不易,請給童長老點贊

審核編輯 黃宇

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • Harmony
    +關注

    關注

    0

    文章

    104

    瀏覽量

    2984
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    harmony-utilsCacheUtil,緩存工具

    harmony-utilsCacheUtil,緩存工具
    的頭像 發表于 07-04 16:36 ?75次閱讀

    harmony-utilsCharUtil,字符工具

    harmony-utilsCharUtil,字符工具
    的頭像 發表于 07-04 16:34 ?69次閱讀

    harmony-utilsCrashUtil,異常相關工具

    harmony-utilsCrashUtil,異常相關工具
    的頭像 發表于 07-04 16:33 ?77次閱讀

    harmony-utilsDeviceUtil,設備相關工具

    harmony-utilsDeviceUtil,設備相關工具
    的頭像 發表于 07-03 18:27 ?122次閱讀

    harmony-utilsDisplayUtil,屏幕相關工具

    harmony-utilsDisplayUtil,屏幕相關工具
    的頭像 發表于 07-03 18:26 ?93次閱讀

    harmony-utilsEmitterUtil,Emitter工具

    harmony-utilsEmitterUtil,Emitter工具
    的頭像 發表于 07-03 18:24 ?108次閱讀

    harmony-utilsFileUtil,文件相關工具

    harmony-utilsFileUtil,文件相關工具
    的頭像 發表于 07-03 18:23 ?106次閱讀

    harmony-utilsFormatUtil,格式化工具

    harmony-utilsFormatUtil,格式化工具
    的頭像 發表于 07-03 18:22 ?108次閱讀

    harmony-utilsImageUtil,圖片相關工具

    harmony-utilsImageUtil,圖片相關工具
    的頭像 發表于 07-03 18:22 ?123次閱讀

    harmony-utilsPreviewUtil,文件預覽工具

    harmony-utilsPreviewUtil,文件預覽工具 harmony-utils 簡介與說明 [
    的頭像 發表于 07-03 11:40 ?91次閱讀

    harmony-utilsSnapshotUtil,截圖相關工具

    harmony-utilsSnapshotUtil,截圖相關工具 harmony-utils
    的頭像 發表于 07-03 11:36 ?80次閱讀

    harmony-utilsWindowUtil,窗口相關工具

    harmony-utilsWindowUtil,窗口相關工具 harmony-utils
    的頭像 發表于 06-30 17:33 ?85次閱讀

    harmony-utilsAuthUtil,生物認證相關工具

    # harmony-utilsAuthUtil,生物認證相關工具 ## harmony-utils
    的頭像 發表于 06-26 17:43 ?89次閱讀

    harmony-utilsNetworkUtil,網絡相關工具

    harmony-utilsNetworkUtil,網絡相關工具 harmony-utils
    的頭像 發表于 06-25 23:46 ?22次閱讀

    harmony-utilsDateUtil,日期工具

    harmony-utilsDateUtil,日期工具
    的頭像 發表于 06-25 22:15 ?21次閱讀
    主站蜘蛛池模板: 金山区| 瑞丽市| 马鞍山市| 拜城县| 开江县| 诸暨市| 玉龙| 监利县| 长阳| 竹溪县| 内江市| 温宿县| 治县。| 阿合奇县| 南雄市| 洪洞县| 定日县| 溧水县| 敦化市| 米易县| 扬中市| 嘉禾县| 阿坝县| 库车县| 广安市| 咸宁市| 广州市| 织金县| 禄丰县| 嘉峪关市| 灌云县| 偃师市| 宜昌市| 镇赉县| 浑源县| 东至县| 永泰县| 富川| 河间市| 望都县| 石林|