Get the city and country name with latitude and longitude (iOS)
I use this function: func getDataCity(tmpLat:Double,tmpLong:Double) { let tmpCLGeocoder = CLGeocoder.init() let tmpDataLoc = CLLocation.init(latitude: tmpLat, longitude: tmpLong) tmpCLGeocoder.reverseGeocodeLocation(tmpDataLoc, completionHandler: {(placemarks,error) in guard let tmpPlacemarks = placemarks else{ return } let placeMark = tmpPlacemarks[0] as CLPlacemark // Country guard let countryLocality = placeMark.country else{ return } // City guard let cityLocality = placeMark.locality else{ return } print(countryLocality) print(cityLocality) }) } When I use coordinates, for example, from B
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.