将Google Maps / Mapquest中的特定道路列入黑名单? [英] Blacklisting specific roads from Google Maps/Mapquest?

查看:122
本文介绍了将Google Maps / Mapquest中的特定道路列入黑名单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期望为Google Maps类型的应用程序构建自定义视图以提供路线指示,但我需要将特定的道路或路段列入黑名单。我不是在说要避开高速公路或收费公路。我一直在浏览谷歌地图和Mapquest API,但还没有发现任何使用。



最初,我只是想手动将特定的道路黑名单,我不希望开车,但最终会希望有某种自动检测或建议。



是否有内置功能支持在Google中列入黑名单特定道路地图或Mapquest?或者是否有任何已知的方法将它们一起破解? 解决方案

正如另一个答案中提到的, Google Maps API。然而,我一直在考虑这个问题,并在黑客攻击类别中提出了一些解决方案。这两者都依赖于Google Maps API的第3版。


  1. 请求路线时,请将provideRouteAlternatives设置为true。循环选择。检查该路线是否通过了您的某个路障。如果是,则放弃该路线并尝试下一个路线。


  2. 对于每个障碍物,预先设置一个或多个替代点路线穿过。例如,如果您想避开某个桥,请确定一个或多个备用桥以便使用。现在,如果某条路线经过了您的某个路障,请将该路障的备用点作为路点添加(将中途停留设置为false)。现在再次运行指导,他们应该避开路障并使用替代品。




  3. 这两种方法都不是最佳的,但取决于你的情况,他们可能会为你工作。


    I'm looking to build a custom view of a Google Maps type of application for providing directions, but I need to blacklist specific roads or sections of roads. I'm not talking just avoiding highways or Toll Roads. I've been looking through the Google Maps and Mapquest APIs but haven't found anything of use yet.

    Initially I'm just looking to manually blacklist specific roads that I do not want to drive on, but eventually would like there to be some sort of automatic detection or suggestion.

    Is there built-in functionality to support blacklisting specific roads in Google Maps or Mapquest? Or is there any known way to hack it together?

    解决方案

    As mentioned in another answer, this functionality is not directly available in the Google Maps API. However, I've been thinking about it, and had a couple of work-around ideas in the "hacking it together" category. Both of these rely on version 3 of the Google Maps API.

    1. When requesting the directions, set provideRouteAlternatives to true. Loop through the alternatives. Check if that route passes through one of your roadblocks. If it does, discard that route and try the next one.

    2. For each roadblock, set up in advance one or more alternate points to route through. For example, if you want to avoid a certain bridge, identify one or more alternate bridges to use. Now, if a route passes through one of your roadblocks, add the alternate point for the for roadblock as a waypoint (with stopover set to false). Now run the directions again and they should avoid the roadblock and use the alternate.

    Neither of these methods are optimal, but depending on your situation, they might work for you.

    这篇关于将Google Maps / Mapquest中的特定道路列入黑名单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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