2011-04-25 55 views
0

我讀了很多話題展開在谷歌地圖API的路線,但我不覺得當我想iPhone:如何從你的應用程序

我想從我與該應用程序推出谷歌地圖API :

[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://maps.google.com/maps?saddr=41.029598,28.972985&daddr=41.033586,28.984546"]] 

但它是開放Safari瀏覽器與谷歌地圖頁面。我想用我的路線打開Goog​​le地圖API。有一張地圖://或其他東西?

感謝您的幫助!

+0

你對模擬器進行測試?如果是,請嘗試使用設備。 – Alkimake 2011-04-25 11:06:12

回答

1

試試這個

UIApplication *app = [UIApplication sharedApplication]; 

    NSURL *url = [[NSURL alloc] initWithString: @"http://maps.google.com/maps?saddr=41.029598,28.972985&daddr=41.033586,28.984546"]; 

    [app openURL:url]; 

    [url release]; 
+0

這正是他所做的,但有一點不同:你的代碼泄露; – cweinberger 2011-04-25 11:11:44

+0

請參閱我更新的代碼。 – 2011-04-25 11:16:00

0

看看在Apple URL Scheme Reference for MapLinks

編輯:你的URL看起來是正確的。看起來你正在模擬器上測試! GoogleMaps應用只能在設備上使用!

+0

這裏有更好的:http://mapki.com/index.php?title = Google_Map_Parameters#Output_Control – osta 2011-04-25 11:06:07

+0

這沒有幫助我! – osta 2011-04-25 11:07:27

+0

看我的編輯;)。你需要使用蘋果方案,因爲谷歌地圖應用程序不支持web應用程序支持的所有參數 – cweinberger 2011-04-25 11:09:48

0

試試這個

NSString *urlstring=[NSString stringWithFormat:@"http://maps.google.com/?&saddr=%@ &daddr=%@",sourceaddress,destinationaddress]; 
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlstring]]; 
相關問題