Advertisement
Guest User

GSMSDK-iOS

a guest
Mar 11th, 2015
1,502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. NSString *urlString = [NSString stringWithFormat:@"%@?origin=%@,%@&destination=%f,%f&sensor=false&waypoints=optimize:true&mode=driving", @"https://maps.googleapis.com/maps/api/directions/json", getmycurrlat, getmycurrlong, LATI, LONGI];
  2.         NSLog(@"my driving api URL --- %@", urlString);
  3.         NSLog(@"you clicked on button %ld", (long)sender.tag);
  4.         NSURL* url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@", urlString]];
  5.         NSURLResponse* res;
  6.         NSError* err;
  7.         NSData* data = [NSURLConnection sendSynchronousRequest:[[NSURLRequest alloc] initWithURL:url] returningResponse:&res error:&err];
  8.         if (data == nil) {
  9.             return;
  10.         }
  11.  
  12.         NSDictionary* dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
  13.         NSDictionary* routes = [dic objectForKey:@"routes"][0];
  14.         NSDictionary* route = [routes objectForKey:@"overview_polyline"];
  15.         NSString* overview_route = [route objectForKey:@"points"];
  16.  
  17.         GMSPath* path = [GMSPath pathFromEncodedPath:overview_route];
  18.         GMSPolyline* polyline = [GMSPolyline polylineWithPath:path];
  19.         polyline.strokeWidth = 5.f;
  20.         polyline.map = self.mapView;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement