2011-01-05 75 views
7

截至目前走的方向,我成功地生成從我用下面的代碼的應用程序與地圖應用方向:生成與地圖應用的iOS

NSString *formattedGroceryAddress = [[NSString stringWithFormat:@"%@",((EnhancedUIActionSheet *)actionSheet).grocery.address] stringByReplacingOccurrencesOfString:@" " withString:@"+"]; 
NSString *routeString = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%@",localDataHelper.userLocation.coordinate.latitude,localDataHelper.userLocation.coordinate.longitude,formattedGroceryAddress]; 
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:routeString]]; 

它打開了地圖應用適當的駕駛方向。事情是,我想在默認情況下使用步行方向打開地圖。也許我可以在我的請求中傳遞另一個參數來執行此操作。

任何人都知道怎麼樣?

謝謝!

回答

27

嗯,我想我應該問之前已搜查更好!

您可以添加dirflg = W請求,它會在行走模式下啓動地圖應用。

這很有趣,因爲蘋果公司表示,他們只是支持一些谷歌地圖不參數包括這一個,但它實際上似乎工作!

有關谷歌地圖的參數的詳細信息:http://mapki.com/wiki/Google_Map_Parameters
有關地圖的更多信息從iOS應用鏈接:http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html

+0

嘿兄弟..鏈接對我的作品,但現在我有我不能讓一個問題回到我的應用程序,我從那裏調用地圖的應用程序。任何想法? – nikesh 2013-02-11 09:02:22

+0

這裏是蘋果文檔的工作網址https://developer.apple.com/library/content/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html – benLIVE 2017-07-31 10:00:09