使用地图应用iOS生成步行路线 [英] Generate walking directions with Maps app iOS

查看:167
本文介绍了使用地图应用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]];

使用适当的驾车指示打开地图应用。问题是,我想默认情况下打开地图步行指示。也许我可以在我的请求中传递另一个参数来做到这一点。



任何人都知道如何?

谢谢! / p>

解决方案

好吧,我想我应该在查询之前进行更好的搜索!



您可以将dirflg = w添加到请求中,并且它将以步行模式启动地图应用程序。



这很有趣,因为Apple表示他们只支持少数Google地图参数包括这一个,但它似乎工作!



有关Google地图参数的更多信息: http://mapki.com/wiki/Google_Map_Parameters

有关iOS应用的地图链接的更多信息: http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html a>


As of now, I successfully generate directions with Maps app from my app with the following code :

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

It opens the Maps app with the appropriate driving directions. The thing is, I'd like to open Maps with the walking directions by default. Maybe I can pass another parameter in my request to do that.

Anybody knows how ?

Thanks !

解决方案

Well I guess I should have searched better before asking !

You can add dirflg=w to the request and it will launch maps app in the walking mode.

It's funny because Apple says they are only supporting a few Google Maps parameters not including this one but it actually seems to work !

For more info on Google Maps parameters : http://mapki.com/wiki/Google_Map_Parameters
For more info on Maps links from iOS apps : http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html

这篇关于使用地图应用iOS生成步行路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆