我的Directions API请求无效,为什么? [英] My Directions API request is Invalid, but Why?

查看:151
本文介绍了我的Directions API请求无效,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://maps.googleapis.com/maps/api/directions/json?origin=Central+Hong+Kong&destination=Sai+Kung&sensor=false&mode=transit

该请求在没有mode = transit参数的情况下仍然可以正常运行,但是结果仅包括行车路线.添加了最后一个参数后,我得到了:

The request works fine without the mode=transit parameter, but the results only include driving directions. With the last parameter added, I get this:

状态":"INVALID_REQUEST"

"status" : "INVALID_REQUEST"

我该怎么做才能使它起作用?肯定有可用的公交选项,

What can I do to make this work? There are definitively transit options available, they are listed in Google Maps.

推荐答案

INVALID_REQUEST 表示提供的请求无效.导致此状态的常见原因包括无效的参数或参数值.

INVALID_REQUEST indicates that the provided request was invalid. Common causes of this status include an invalid parameter or parameter value.

如果将模式设置为过境",则还必须指定出发时间"或到达时间".

If you set the mode to "transit" you must also specify either a departure_time or an arrival_time.

摘自文档

模式(默认为行驶)—指定计算方向时要使用的运输方式.有效值在出行模式"中指定.如果将模式设置为过境",则还必须指定出发时间"或到达时间".

mode (defaults to driving) — Specifies the mode of transport to use when calculating directions. Valid values are specified in Travel Modes. If you set the mode to "transit" you must also specify either a departure_time or an arrival_time.

如果将"departure_time"添加到您问题中的请求,则会返回结果:

If "departure_time" is added to the request in your question, it returns a result:

查看全文

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