簡體   English   中英

使用Maps應用iOS生成步行路線

[英]Generate walking directions with Maps app iOS

到目前為止,我已使用以下代碼從我的應用程序中成功使用Maps應用程序生成路線:

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]];

它將以適當的行駛方向打開“地圖”應用。 事情是,我想默認打開帶有步行路線的地圖。 也許我可以在請求中傳遞另一個參數來做到這一點。

有人知道嗎?

謝謝 !

好吧,我想我應該在詢問之前做得更好!

您可以將dirflg = w添加到請求中,它將以步行模式啟動地圖應用。

有趣的是,蘋果表示他們僅支持一些Google Maps參數,但不包括該參數,但實際上似乎可以使用!

有關Google Maps參數的更多信息: http : //mapki.com/wiki/Google_Map_Parameters
有關來自iOS應用的“地圖”鏈接的更多信息,請訪問: http : //developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM