Satish A
Satish A

Reputation: 584

geocode 2 or more locations at same time

I am trying to get locations from multiple address strings.

I've used below code for single string.

NSString *addressStr = @"Neeru'sEmporio,RoadNumber36,Venkatagiri,Hyderabad,AndhraPradesh,India";  //String after removing spaces

    [[CLGeocoder new] geocodeAddressString:orgin completionHandler:^(NSArray *placemarks, NSError *error)
     {
         if(!error)
         {
             CLPlacemark *placemark = [placemarks objectAtIndex:0];
             NSLog(@"%f",placemark.location.coordinate.latitude);
             NSLog(@"%f",placemark.location.coordinate.longitude);
             NSLog(@"%@",[NSString stringWithFormat:@"%@",[placemark description]]);
         }
         else
         {
             NSLog(@"There was a forward geocoding error\n%@",[error localizedDescription]);
         }
     }
     ];

How to get two or more locations from multiple address strings at a time. i.e., want individual lat long for every individual string and after getting all locations I need to run some other code.

Please help. Thanks in Advance.

Upvotes: 2

Views: 408

Answers (2)

aman.sood
aman.sood

Reputation: 874

Use this instead https://maps.googleapis.com/maps/api/geocode/json?address=%@&key=%@

pass address as esc_add and create an google api key using The Google Maps Geocoding API

One more thing replace all spaces " " with "+"

example https://maps.googleapis.com/maps/api/geocode/json?address=Neeru's+Emporio,Road+Number+36,Venkatagiri,Hyderabad,Andhra+Pradesh,India&key=YOUR_API_KEY

It will work fine

Upvotes: 2

Martin Makarsky
Martin Makarsky

Reputation: 2650

There are limits for using apple`s geocoder (eg. batch requesting). For more info see apple dev forum (apple stuff answers). You can use another services like google (there are limits too) or use own solution built on open street maps (you can use eg. xapi or overpass api).

Upvotes: 0

Related Questions