打开谷歌地图巴士方向 [英] open google maps to bus directions

查看:104
本文介绍了打开谷歌地图巴士方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  NSString * urlString => 

我知道您可以通过执行下列操作来打开Goog​​le地图应用程序, @ http://maps.google.com/maps?saddr=London+UK&daddr=Birmingham+UK;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

但是有一个参数可以自动切换到总线方向吗? Apple的开发者文档似乎没有提及任何有关它的内容:

$ b

https://developer.apple.com/iphone/library/featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html#//apple_ref / doc / uid / TP40007894

解决方案

From

>

  • dirflg = h - 打开避开高速公路
    路线寻找模式。 b路线查找模式。

  • dirflg = r - 打开公共交通 - 仅适用于某些区域。
  • dirflg = d - 切换到驾驶
    方向。

  • >

    所以你的网址:

      NSString * urlString = @http:// maps.google.com/maps?saddr=London+UK&daddr=Birmingham+UK; 

    成为:

      NSString * urlString = @http://maps.google.com/maps?saddr=London+UK&daddr=Birmingham+UK&dirflg=r; 



    N.B。支持公共交通路线类型的数据并不总是可用的。我尝试了您在样本中使用的区域(伦敦,伯明翰),发现它不被支持。


    I realise that you can open the google maps app ready for directions by doing something like this:

    NSString* urlString = @"http://maps.google.com/maps?saddr=London+UK&daddr=Birmingham+UK";
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: urlString]];
    

    But is there a parameter I can add to automatically switch to bus directions? Apple's developer document doesn't seem to mention anything about it:

    https://developer.apple.com/iphone/library/featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html#//apple_ref/doc/uid/TP40007894

    解决方案

    From MapKiWiki:

    dirflg Route type:

    • dirflg=h - Switches on "Avoid Highways" route finding mode.
    • dirflg=t - Switches on "Avoid Tolls" route finding mode.
    • dirflg=r - Switches on "Public Transit" - only works in some areas.
    • dirflg=w - Switches to walking directions - still in beta.
    • dirflg=d - Switches to driving directions.

    So your URL:

    NSString* urlString = @"http://maps.google.com/maps?saddr=London+UK&daddr=Birmingham+UK";
    

    Becomes:

    NSString* urlString = @"http://maps.google.com/maps?saddr=London+UK&daddr=Birmingham+UK&dirflg=r";
    

    N.B. The data supporting public transit route types are not always available. I tried the area you used in your sample (London, Birmingham) and found it was not supported.

    这篇关于打开谷歌地图巴士方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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