ALL google maps Directions web service API requests with mode=transit return INVALID_REQUEST

匿名 (未验证) 提交于 2019-12-03 08:54:24

问题:

Here are a few URLs that return results with walking or driving but not with transit (i.e., change mode to walking or driving and you will see results)

http://maps.googleapis.com/maps/api/directions/json?origin=EC3N4AB&destination=EC4M8AD&sensor=false&mode=transit

http://maps.googleapis.com/maps/api/directions/json?origin=Toledo&destination=Madrid&region=es&sensor=false&mode=transit

I cant get a single response with mode=transit. Notice that the second URL is straight from API documentation

Anyone else noticing the same thing?

回答1:

Sorry. Its not the global thing

E.g, this doesnt work: http://maps.googleapis.com/maps/api/directions/json?origin=san+francisco&destination=seattle&sensor=false&mode=transit

But, this does again: http://maps.googleapis.com/maps/api/directions/json?origin=san+francisco&destination=seattle&sensor=false&mode=transit&departure_time=1343376768

Its not the global issue. Its that google made departure_time or arrival_time as a mandatory field. This is a recent change to their API.

Thanks for all your help



回答2:

Transit directions don't work globally. For example, this request works:

http://maps.googleapis.com/maps/api/directions/json?origin=san+francisco&destination=seattle&sensor=false 

On the other hand if you go to maps.google.com and attempt to get transit directions via the UI from Toledo to Madrid, it notes the request is outside the coverage area. The way the API returns this information is via the INVALID_REQUEST status.



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