嘿我有一些坐标[“37.7”,“-122.4”],我试图用来反转geoCode。所以我可以得到一个简单的UI标签的城市和国家。 但是,当我使用CLLocation通过用placeMark标准的administrativeArea var/method来获取状态时,它返回nil。ClLocation地标不返回管理区域
▿一些:1个元件 - 0:旧金山湾,旧金山湾,旧金山,美国@ < + 37.80000000,-122.50000000> +/-100.00米,区域CLCircularRegion(标识符:” < + 37.79999999,-122.50000000>半径141.72' ,中心:< + 37.79999999,-122.50000000>,半径:141.72米)
这是我从完成处理回。这使得很明显,没有任何状态从这个返回。为什么会这样,我还能如何获得这个状态。
封闭的代码块控制这个行动所有帮助表示赞赏。
CLGeocoder().reverseGeocodeLocation(location, completionHandler: { (placeMark, error) in
if error != nil{
print("There was an error")
}else{
if let place = placeMark?[0]{
print(place)
print(place.locality ?? "")
print(place.subAdministrativeArea ?? "")
let myAttribute = [NSAttributedStringKey.font:UIFont(name: "Times New Roman", size: 15.3)!]
let myAttrString = NSAttributedString(string: place.locality ?? "", attributes: myAttribute)
locLabel.attributedText = myAttrString
}
}
})
如果您觉得数据库中存在错误,则可能会对Apple提出错误。 – matt
是的,我刚刚意识到我身处水体 –