Satish A February 2016

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.

Answers


martin February 2016

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).


aman.sood February 2016

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

Post Status

Asked in February 2016
Viewed 1,616 times
Voted 4
Answered 2 times

Search




Leave an answer