CLGeocoder returns wrong results when city name is equal to some country's name (and not only)

前端 未结 4 505
抹茶落季
抹茶落季 2020-12-17 14:16

In one of my apps I need to add an ability to find a city by its name. I am using CLGeocoder to achieve this and I want it to have a behaviour identical to iOS

4条回答
  •  天命终不由人
    2020-12-17 14:45

    CLGeocoder requests are rate limited and if the app goes over the threshold, further requests may not be fulfilled. CLGeocoder requires network connection which may be limiting under some circumstances and the response from the server is not always instant. If you do not insist on CLGeocoder, local database might give you more flexibility and possibly better user experience.

    Take a look at the cities???.zip on GeoNames, for an alternative solution where you would import the data to a local database.

提交回复
热议问题