diff --git a/pages/SDKIntegration/SDKIntegration.vue b/pages/SDKIntegration/SDKIntegration.vue index 1d9f2aa6ff9f5c238b6cb284050e21587fdb8485..9ae4b9884bc012f95b52b87cb27ad371c0f89216 100644 --- a/pages/SDKIntegration/SDKIntegration.vue +++ b/pages/SDKIntegration/SDKIntegration.vue @@ -20,8 +20,10 @@ testGetlocation:function(e){ requestPremission(); - var locationRet = getLocation(); - console.log(locationRet); + var locationRet = getLocation(function(res){ + console.log(res); + }); + }, } } diff --git a/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts b/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts index ba2f8662a5cba7b64c88a26b1b82ec5d782c231e..cdf856b1a9610d71270deab2db4c8f5e657645d4 100644 --- a/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts +++ b/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts @@ -62,7 +62,10 @@ export function getLocation(changeListener: (res: string) => void) { // 获取当前的地址回调 let mLocationManager = TencentLocationManager.getInstance(getAppContext()); - let mLocationListener = new SingleLocationListener(changeListener); + + let mLocationListener = new SingleLocationListener( function(newRes:string){ + changeListener(newRes); + }); mLocationManager.requestSingleFreshLocation(null, mLocationListener, Looper.getMainLooper()); // 请求权限 return { name: "getLocation"};