Instantly share code, notes, and snippets.

Embed
What would you like to do?
Swift Geocoder
let geocoder = CLGeocoder()
let location = CLLocation(latitude: 47.640320, longitude: -122.134400)
geocoder.reverseGeocodeLocation(location) { (addressList, error) in
if let error = error {
print("Unable to Reverse Geocode Location (\(error))")
} else {
print(addressList?.first?.compactAddress ?? "No Matching Addresses Found")
}
}
extension CLPlacemark {
var compactAddress: String {
return "\(thoroughfare ?? ""), \(locality ?? ""), \(country ?? "")"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment