From 924f25da18fe391f31a0c1a531702d4ee3fc36b5 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Tue, 6 Sep 2022 19:56:34 +0800 Subject: [PATCH] location page ing --- manifest.json | 4 ++-- .../utssdk/app-android/index.uts | 22 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index 78d09bc..492471d 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "HelloUTS", "appid" : "__UNI__70BE9D0", "description" : "", - "versionName" : "1.0.5", - "versionCode" : "105", + "versionName" : "1.0.6", + "versionCode" : "106", "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts b/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts index 0ed35a3..ba2f866 100644 --- a/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts +++ b/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts @@ -34,21 +34,35 @@ export function requestPremission() { class SingleLocationListener extends TencentLocationListener { + + constructor(changeListener: (res: string) => void){ + super(); + } + override onLocationChanged(location:TencentLocation , error:Int , - reason:string ):Unit{ + reason:string ):void{ + + if(error == 0){ + let locationName = location.name; + let locationAddress = location.address; + let latitude = location.latitude; + let longitude = location.longitude; + } console.log(location); + console.log(error); + console.log(reason); } - override onStatusUpdate(name:string, status:Int, desc:string ):Unit{ + override onStatusUpdate(name:string, status:Int, desc:string ):void{ console.log(name); } } -export function getLocation() { +export function getLocation(changeListener: (res: string) => void) { // 获取当前的地址回调 let mLocationManager = TencentLocationManager.getInstance(getAppContext()); - let mLocationListener = new SingleLocationListener(); + let mLocationListener = new SingleLocationListener(changeListener); mLocationManager.requestSingleFreshLocation(null, mLocationListener, Looper.getMainLooper()); // 请求权限 return { name: "getLocation"}; -- GitLab