Find city name and country from latitude and longitude in Swift

前端 未结 11 1956
既然无缘
既然无缘 2020-12-12 22:58

I\'m working on application in Swift3 and I have letter problem i can\'t find the answer for it.

How can I know city name and country short names base on latitud

11条回答
  •  天涯浪人
    2020-12-12 23:21

    You can use CLGeocoder, from CoreLocation, for that. From Apple documentation (emphasizes mine):

    A single-shot object for converting between geographic coordinates and place names.

    The CLGeocoder class provides services for converting between a coordinate (specified as a latitude and longitude) and the user-friendly representation of that coordinate. A user-friendly representation of the coordinate typically consists of the street, city, state, and country information corresponding to the given location...

    This service is unrelated to MapKit and, as such, don't require you use/show a map in your app at all.

提交回复
热议问题