Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. NSString *baseUrl=[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/directions/json? origin=indore&destination=bhopal&key=%@&alternatives=true”,APIKey];
  2.  
  3. NSURL *url = [NSURL URLWithString:[baseUrl
  4. stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
  5. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  6.  
  7. [NSURLConnection sendAsynchronousRequest:request queue:
  8. [NSOperationQueue mainQueue] completionHandler:^(NSURLResponse
  9. *response, NSData *data, NSError *connectionError) {
  10. if(!connectionError){
  11. NSDictionary *result= [NSJSONSerialization JSONObjectWithData:data
  12. options:0 error:nil];
  13. // this will return all possible roots
  14. NSArray *routes = [result objectForKey:@"routes"];
  15. //add The polyline between locations.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement