kCLErrorDomain error 2 after geocoding repeatedly with CLGeocoder kCLErrorDomain error 2 after geocoding repeatedly with CLGeocoder ios ios

kCLErrorDomain error 2 after geocoding repeatedly with CLGeocoder


I believe the reason is the following:
Apple's geocoder does not answer every request in the same way. Instead, the first requests from a certain device are answered quickly, but if the device has sent say 100 requests or more, the answers arrive slower and slower or requests are not answered at all, which might cause your error.
When you reload the view controller, this simply takes time, and the geocoding server is more willing to answer again.Essentially, you cannot do anything about it, since the geocoder sever wants to protect itself from being overloaded by requests from a single device. You simply had to limit the number of requests that you send there.
BTW: The docs say "you should not send more than one geocoding request per minute".


Note that this same error is returned when the device is offline.


I had this problem while picking location for messenger application. My solution was to introduce delay of 3 seconds, after user stop panning map, before geocoder call. To ensure that user want exactly that location.