From 91cc21ae92717d0c22f61a580a0634f2d92296f9 Mon Sep 17 00:00:00 2001 From: XHY Date: Mon, 26 Jun 2023 18:35:58 +0800 Subject: [PATCH] =?UTF-8?q?iOS=E5=B9=B3=E5=8F=B0=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?=E5=9C=A8=E6=B2=A1=E6=9C=89=E7=BD=91=E7=BB=9C=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E8=B0=83=E7=94=A8=E8=85=BE=E8=AE=AF=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=E6=8F=92=E4=BB=B6=20API=20=E5=BA=94=E7=94=A8=E4=BC=9A?= =?UTF-8?q?=E9=97=AA=E9=80=80=E7=9A=84Bug=20[=E8=AF=A6=E6=83=85](https://a?= =?UTF-8?q?sk.dcloud.net.cn/question/172744)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utssdk/app-ios/index.uts | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/uni_modules/uts-tencentgeolocation/utssdk/app-ios/index.uts b/uni_modules/uts-tencentgeolocation/utssdk/app-ios/index.uts index 3190d49..51ac248 100644 --- a/uni_modules/uts-tencentgeolocation/utssdk/app-ios/index.uts +++ b/uni_modules/uts-tencentgeolocation/utssdk/app-ios/index.uts @@ -75,9 +75,21 @@ class LBSLocation implements TencentLBSLocationManagerDelegate { // 请求单次定位信息 this.locationManager.requestLocation(with = requestLevel, locationTimeout = 10, completionBlock = (location?: TencentLBSLocation, err?: NSError): void => { if (location != null) { + + // 判断 name、address 是否有值 + var name = "" + var address = "" + if (location!.name != null) { + name = location!.name! + } + + if (location!.address != null) { + address = location!.address! + } + let response: LocationResponse = { - name: location!.name, - address: location!.address, + name: name, + address: address, latitude: Number(location!.location.coordinate.latitude), longitude: Number(location!.location.coordinate.longitude) } @@ -115,15 +127,27 @@ class LBSLocation implements TencentLBSLocationManagerDelegate { } // 实现定位出错的 delegate 方法 - tencentLBSLocationManager(manager: TencentLBSLocationManager, error: NSError) { + tencentLBSLocationManager(manager: TencentLBSLocationManager, @argumentLabel("didFailWithError") error: NSError) { this.locationOptions?.fail(error.localizedDescription) } // 实现位置更新的 delegate 方法 tencentLBSLocationManager(manager: TencentLBSLocationManager, @argumentLabel("didUpdate") location: TencentLBSLocation) { + + // 判断 name、address 是否有值 + var name = "" + var address = "" + if (location.name != null) { + name = location.name! + } + + if (location.address != null) { + address = location.address! + } + let response: LocationResponse = { - name: location.name, - address: location.address, + name: name, + address: address, latitude: Number(location.location.coordinate.latitude), longitude: Number(location.location.coordinate.longitude) } -- GitLab