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.
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 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With