我正在使用reverseGeocodeLocation,有时使用给定的纬度和经度,不会返回'subThoroughfare'和'通道'。如果有办法将最近的'subThoroughfare'和'通道'送到那个地方?
到目前为止,这是我的代码:
var nearAddressString = ""
CLGeocoder().reverseGeocodeLocation(userCLLocation, completionHandler: { (placemarks, error) -> Void in
if error != nil {
print(error!)
} else {
if let p = placemarks?[0] {
let subThroughfare = p.subThoroughfare ?? ""
let thoroughfare = p.thoroughfare ?? ""
let subLocality = p.subLocality ?? ""
let subAdministrativeArea = p.subAdministrativeArea ?? ""
let postalCode = p.postalCode ?? ""
nearAddressString = "\(subThroughfare) \(thoroughfare) \n \(subLocality) \n \(subAdministrativeArea) \n \(postalCode)"
print(nearAddressString)
} else {
print("Problem with the data received from geocoder")
}
}
})