How to avoid both tolls and highways for Restrictions in Google Directions API?

痴心易碎 提交于 2019-12-01 13:03:39

&avoid=tolls|highways

Search for "avoid=tolls|highways|ferries" on: https://developers.google.com/maps/documentation/directions/

I'm stuck on the "attempt to" avoid highways and tolls too. The docs clearly state "Note: the addition of restrictions does not preclude routes that include the restricted feature; it simply biases the result to more favorable routes"...so favorable = ignored arguments.

You can pass in both arguments...http://maps.google.com/maps/api/directions/xml?alternatives=true&units=imperial&avoid=tolls&avoid=highways...

Here's a link to the latest docs.... https://developers.google.com/maps/documentation/directions/

I ran into the same issue, so I did some tests and it appears as if &avoid=tolls|highways is the correct usage.

Going from Portland, OR to San Francisco, CA has tolls and highways. If you go to maps.google.com and route between the two, selecting different options, you find that Google gives you the same route for avoiding highways as avoiding highways and tolls.

When doing an API request &avoid=tolls|highways results in the same as &avoid=highways|tolls.

&avoid=tolls,highways results in not avoiding either.

&avoid=tolls&avoid=highways results in only avoiding tolls.

This all leads me to infer that Google must be reading both variables when you pass them with a |. however, avoiding tolls and highways often results in the same directions as just avoiding highways.

Currently there seems to be a bug in the Google Directions API (not the client library). Multiple restrictions are not identified, e.g.&avoid=highways|tolls does not work but single do &avoid=highways and &avoid=tolls.

See answer: https://productforums.google.com/forum/#!topic/maps/WSp_qn6ou6I

I've opened a bug ticket for this on the Directions API bug tracker as there was none there already https://code.google.com/p/gmaps-api-issues/issues/detail?id=10696

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!