6

Currently i am developing an iPhone application where i have to show user's current city and location for which i am using Mapkit Framework.When i build the application it works fine and show me the exact city details .But right now when i try to build the application again application shows following error message in my log

/SourceCache/ProtocolBuffer_Sim/ProtocolBuffer-26/Runtime/PBRequester.m:523 server returned error: 503

reverseGeocoder: didFailWithError:Error Domain=PBRequesterErrorDomain Code=6001 "Operation could not be completed. (PBRequesterErrorDomain error 6001.)"

Is any body facing the same issue and how can i resolve it?

raaz
  • 12,410
  • 22
  • 64
  • 81

4 Answers4

9

I am pretty sure this is happening because you are in testing, and using the reverse geocoder too much and Google's servers know that. So, it has basically blocked you for a while. Try again later and see if it works.

You need to make sure that you are not calling the geocoder more than once every 60 seconds.

Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412
  • Hi, Nic you are right mostly the application shows this error message upto 1 PM in India and after that it works fine, i think google may be updating their server at this time. – raaz Jun 10 '10 at 12:24
  • Is that seriously the reason? I have a pin that the user can drag around and it updates with the new address... If this is the case, the user won't be able to drag the pin around and see it updating unless it is less than once every 60 seconds...! – jowie Jan 20 '12 at 14:58
  • Also I've noticed that usually, the first 503 I get is the first time I request it. After using it a couple of times, the 503 errors stop happening... – jowie Jan 20 '12 at 15:26
2

I find out!
Well, now we'll have to use CLGeocoder, but if you want still to use MKReverseGeocoder, you MUST not call [geocoder start] twice, even if the geocode object is a fresh new one! For example, DON'T do this:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{
        MKReverseGeocoder *geoCoder = [[[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate] autorelease];
        geoCoder.delegate = self;
        [geoCoder start];
}

Or you'll get an arror: the location manager update position function is being called as soon as a new position is detected. As the accuracy is getting better and better, a new fresh new posistion is being sent to "didUpdateToLocation".
But creating a new object MKReverseGeocoder each time a position is found is a bad idea! So, you've got a few solutions:
- Put a boolean that is true when geocoder is started. Then in didFindPlacemark (geocoder's), you should stop the geocoder with [geocoder cancel] and set your boolean to false.
- Make geocoder variable not local and manange a [geocoder cancel] + realease and create a new one and[geocoder start] each time didUpdateToLocation is beeing called.
- Any other way to avoid [geocoder start] to be called twice

I used the first solution and never get the 503 error anymore.

Dugh
  • 171
  • 1
  • 3
  • Unfortunately did not work for me. Even cancelling it every time, the MKReverseGeocoder throws a 503 if it is called too regularly. – jowie Jan 20 '12 at 15:19
2

For me, MKReverseGeocoder was failing with 503 far too many times. It would also fail the first time it was requested, well after 60 seconds had passed. As a result, I decided to give up using it and instead decided to access Google's API directly using NSURLRequest via a service I created that also parses the result as a JSON String using the SBJSON Framework (very useful).

From my service, I call the following URL as follows:

NSString *urlStr = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=true", coordinate.latitude, coordinate.longitude];

where coordinate is a CLLocationCoordinate2D.

I realise this is a long way around the problem, but since converting to this system I have had no issues!

jowie
  • 8,028
  • 8
  • 55
  • 94
0

It can happen at random, depending on the server's status.

Nick Toumpelis
  • 2,717
  • 22
  • 38