mirror of
https://github.com/jphong1111/awesome-ios-developer.git
synced 2025-01-03 13:31:09 +07:00
Update LocationManager.swift
This commit is contained in:
parent
aaaa1b83a9
commit
7102104730
@ -61,3 +61,18 @@ extension LocationManager: CLLocationManagerDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension LocationManager: MKLocalSearchCompleterDelegate {
|
||||||
|
func getPlaceLocation(with location: CLLocation, completion: @escaping ((String?) -> Void)) {
|
||||||
|
let geoCoder = CLGeocoder()
|
||||||
|
geoCoder.reverseGeocodeLocation(location, preferredLocale: .current) { place, error in
|
||||||
|
guard let place = place?.last, error == nil else {
|
||||||
|
completion("")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let joinedAddressArray = [place.thoroughfare, place.locality, place.administrativeArea, place.country, place.postalCode].compactMap { $0 }.joined(separator: " ")
|
||||||
|
|
||||||
|
completion(joinedAddressArray)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user