如何从iOS应用启动Google地图导航?

时间:2015-12-07 16:45:20

标签: ios google-maps google-maps-api-3

我可以使用[NSURL URLWithString:@"comgooglemaps://...."]打开Goog​​le地图应用 但是如何打开导航模式?

1 个答案:

答案 0 :(得分:1)

此处说明导航模式,"向您的应用添加导航" :https://developers.google.com/maps/documentation/ios-sdk/urlscheme

试试这段代码:

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];
}