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

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

问题描述

我希望构建 Google 地图类型的应用程序的自定义视图以提供路线,但我需要将特定道路或道路部分列入黑名单.我说的不仅仅是避开高速公路或收费公路.我一直在浏览 Google Maps 和 Mapquest API,但还没有找到任何有用的东西.

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.

是否有内置功能支持将 Google 地图或 Mapquest 中的特定道路列入黑名单?或者有什么已知的方法可以一起破解它?

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?

推荐答案

如另一个答案中所述,此功能在 Google Maps API 中不直接可用.但是,我一直在考虑它,并且在将其组合在一起"类别中有几个变通的想法.这两者都依赖于 Google Maps API 的第 3 版.

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. 请求路线时,将 provideRouteAlternatives 设置为 true.循环选择替代方案.检查该路线是否穿过您的路障之一.如果是,则放弃该路由并尝试下一条.

  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.

对于每个路障,提前设置一个或多个备用点以通过.例如,如果您想避开某个桥,请确定要使用的一个或多个备用桥.现在,如果路线穿过您的路障之一,请将 for 路障的备用点添加为路标(将中途停留设置为 false).现在再次运行路线,他们应该避开路障并使用备用路线.

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 地图/Mapquest 中的特定道路列入黑名单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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