I am using
-(void) getRouteData :(double)startPointLatitude :(double)startPointLongitude :(double)stopPointLatitude :(double)stopPointLongitude{
NSString *url = @"http://maps.apple.com/maps/api/directions/json?";
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"POST"];
[request setTimeoutInterval:15];
NSString *postString;
postString = [@"" stringByAppendingFormat: @"origin=%f,%f&destination=%f,%f&sensor=true&mode=driving", startPointLatitude, startPointLongitude, stopPointLatitude, stopPointLongitude];
NSLog(@"%@%@",url, postString);
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
Boolean isDataGet = false;
if (theConnection) {
NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *result = [NSString stringWithFormat:@"%@", [self hexToString:data]];
NSLog(@"result = %@", result);
}
}
to draw path initial and final points on google map but I am getting
{
"routes" : [],
"status" : "REQUEST_DENIED"
}
Also when I add api key it does not work either. (I have enabled places API too)
I solved problem by this function