提交 91cc21ae 编写于 作者: DCloud_iOS_XHY's avatar DCloud_iOS_XHY

iOS平台 修复 在没有网络的情况下调用腾讯定位插件 API 应用会闪退的Bug [详情](https://ask.dcloud.net.cn/question/172744)

上级 5a508ff2
...@@ -75,9 +75,21 @@ class LBSLocation implements TencentLBSLocationManagerDelegate { ...@@ -75,9 +75,21 @@ class LBSLocation implements TencentLBSLocationManagerDelegate {
// 请求单次定位信息 // 请求单次定位信息
this.locationManager.requestLocation(with = requestLevel, locationTimeout = 10, completionBlock = (location?: TencentLBSLocation, err?: NSError): void => { this.locationManager.requestLocation(with = requestLevel, locationTimeout = 10, completionBlock = (location?: TencentLBSLocation, err?: NSError): void => {
if (location != null) { 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 = { let response: LocationResponse = {
name: location!.name, name: name,
address: location!.address, address: address,
latitude: Number(location!.location.coordinate.latitude), latitude: Number(location!.location.coordinate.latitude),
longitude: Number(location!.location.coordinate.longitude) longitude: Number(location!.location.coordinate.longitude)
} }
...@@ -115,15 +127,27 @@ class LBSLocation implements TencentLBSLocationManagerDelegate { ...@@ -115,15 +127,27 @@ class LBSLocation implements TencentLBSLocationManagerDelegate {
} }
// 实现定位出错的 delegate 方法 // 实现定位出错的 delegate 方法
tencentLBSLocationManager(manager: TencentLBSLocationManager, error: NSError) { tencentLBSLocationManager(manager: TencentLBSLocationManager, @argumentLabel("didFailWithError") error: NSError) {
this.locationOptions?.fail(error.localizedDescription) this.locationOptions?.fail(error.localizedDescription)
} }
// 实现位置更新的 delegate 方法 // 实现位置更新的 delegate 方法
tencentLBSLocationManager(manager: TencentLBSLocationManager, @argumentLabel("didUpdate") location: TencentLBSLocation) { 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 = { let response: LocationResponse = {
name: location.name, name: name,
address: location.address, address: address,
latitude: Number(location.location.coordinate.latitude), latitude: Number(location.location.coordinate.latitude),
longitude: Number(location.location.coordinate.longitude) longitude: Number(location.location.coordinate.longitude)
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册