danteCore
danteCore

Reputation: 21

How to launch Google Maps Navigation from iOS app?

I can open Google maps app using [NSURL URLWithString:@"comgooglemaps://...."] But how to open Navigation mode?

Upvotes: 0

Views: 1238

Answers (1)

smy
smy

Reputation: 36

The navigation mode is explained here, "Add navigation to your app" : https://developers.google.com/maps/documentation/ios-sdk/urlscheme

Try this code :

NSURL *testURL = [NSURL URLWithString:@"comgooglemaps-x-callback://"];
if ([[UIApplication sharedApplication] canOpenURL:testURL]) {
  NSString *directionsRequest = @"comgooglemaps-x-callback://" + @"?daddr=John+F.+Kennedy+International+Airport,+Van+Wyck+Expressway,+Jamaica,+New+York" + @"&x-success=sourceapp://?resume=true&x-source=AirApp";
  NSURL *directionsURL = [NSURL URLWithString:directionsRequest];
  [[UIApplication sharedApplication] openURL:directionsURL];
}

Upvotes: 1

Related Questions