on-internet
← Community

Get the city and country name with latitude and longitude (iOS)

Stack Overflow ·

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

Comments

Sign in or sign up to comment and upvote.

No comments yet.