Xcode 谷歌地图导航
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3979201/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode google map navigation
提问by BOMEz
I currently have an application which will drop pins onto various points of interest on a map, all done programmatically on the iPhone.
我目前有一个应用程序,可以将图钉放置在地图上的各个兴趣点上,所有这些都是在 iPhone 上以编程方式完成的。
What I am aiming to get done now is to allow a user to navigate to that location and get turn by turn directions by calling up the built in navigation tools on the iPhone.
我现在想要完成的是允许用户导航到该位置并通过调用 iPhone 上的内置导航工具来获得转弯方向。
Is there anyway that I can do this? I've scoured the developer center and searched both google and here and couldn't find anything about this.
无论如何,我可以做到这一点吗?我已经搜索了开发人员中心并搜索了谷歌和这里,但找不到任何关于此的信息。
回答by Thomas Clayson
You're not allowed to use google directions within your app. The only way you can do this is to send them to the google maps application as per:
您不得在您的应用中使用 google 路线。您可以执行此操作的唯一方法是按照以下方式将它们发送到谷歌地图应用程序:
- (void)getDirections {
CLLocationCoordinate2D start = { (startLatitude), (startLongitude) };
CLLocationCoordinate2D end = { (endLatitude), (endLongitude) };
NSString *googleMapsURLString = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f", start.latitude, start.longitude, end.latitude, end.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];
}