I had similar problem i needed to have direction path to be drawn on google map using same google maps ios sdk. What i did was i accessed Google Distance API.
I extracted the html_instructions & end_location from API using following code.
I had these variables defined as property
@property NSMutableArray *detailedSteps;
@property (strong, nonatomic) IBOutlet GMSMapView *mapview;
And Following code to extract the end_location & html_instructions
NSURL *url=[[NSURL alloc] initWithString:[NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/json?origin=ahmedabad&destination=%@",self.city]];
NSURLResponse *res;
NSError *err;
NSData *data=[NSURLConnection sendSynchronousRequest:[[NSURLRequest alloc] initWithURL:url] returningResponse:&res error:&err];
NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSArray *routes=dic[@"routes"];
NSArray *legs=routes[0][@"legs"];
NSArray *steps=legs[0][@"steps"];
NSMutableArray *textsteps=[[NSMutableArray alloc] init];
NSMutableArray *latlong=[[NSMutableArray alloc]init];
for(int i=0; i< [steps count]; i++){
NSString *html=steps[i][@"html_instructions"];
[latlong addObject:steps[i][@"end_location"]];
[textsteps addObject:html];
}
self.detailedSteps=textsteps;
[self showDirection:latlong];
And here is my method showDirection which draws polygon on the map. Here i am passing the latlong array. Which is actually end_location array.
-(void)showDirection:(NSMutableArray*) latlong{
GMSMutablePath *path = [GMSMutablePath path];
for(int i=0; i<[latlong count]; i++){
double lat=[latlong[i][@"lat"] doubleValue];
double lng=[latlong[i][@"lng"] doubleValue];
[path addLatitude:lat longitude:lng];
}
NSLog(@"Direction path");
GMSPolyline *polyline = [GMSPolyline polylineWithPath:path];
polyline.strokeColor = [UIColor blueColor];
polyline.strokeWidth = 5.f;
polyline.map = self.mapview ;
}