2010-10-20 93 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