2010-10-20 99 views
1

我目前有一个应用程序将放置到地图上的各种兴趣点上,所有这些都是在iPhone上以编程方式完成的。Xcode谷歌地图导航

我现在想要完成的是让用户导航到该位置并通过调用iPhone上的内置导航工具来轮到方向。

无论如何,我可以做到这一点?我搜索了开发人员中心并搜索了谷歌和这里,也找不到任何关于此的信息。

回答

2

您的应用中不允许使用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]]; 

} 
+0

我试过了您发布的代码,它会打开浏览器。虽然它确实让我更接近我的目标,但我确实找到了一个可在本地打开本地地图搜索工具的应用程序:http://itunes.apple.com/us/app/rutters-store-finder/id329882310?mt = 8 。 – BOMEz 2010-10-20 16:40:57