iphoneobjective-cmapkitclgeocoder

Need more coordinates from CLGeocoder than the limit


following code is returning me coordinates only for first 10 addresses. But i need more than 100 to store that in a database. is there a limit of geocoder? how can i do it ?

 for(int i=0;i<count;i++)
{

    CLGeocoder *geoCode = [[CLGeocoder alloc] init];

    [geoCode geocodeAddressString:strcity completionHandler:^(NSArray *placemarks, NSError *error)
     {
         if (!error)
         {
             CLPlacemark *place = [placemarks objectAtIndex:0];
             CLLocation *location = place.location;
             CLLocationCoordinate2D coord = location.coordinate;

             NSString *tempLati=[[NSString alloc]initWithFormat:@"%g",coord.latitude];
             NSString *tempLongi=[[NSString alloc]initWithFormat:@"%g",coord.longitude];




             [objCountries.countryLatitude addObject:tempLati];
             [objCountries.countryLongitude addObject:tempLongi];

             [geoCode cancelGeocode];
         }
     }];


}

Solution

  • iOS throttles CLGeocoder requests, it varies but generally allows 50 or so requests at a time. The time period is an unknown. What you can do is code it to geocode a chunk at a time, leaving an adequate pause in between. Wherever possible once read you should store the result so you don't request the same geocode again. Take note of the CLGeocoder documentation here : CLGeocoder . Apple can restrict you or even suspend your developer account if the gecoding services are abused.