我的Directions API请求无效,为什么?

编程入门 行业动态 更新时间:2024-10-27 18:21:55
本文介绍了我的Directions API请求无效,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

maps.googleapis/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"

我该怎么做才能使它起作用?肯定有可用的公交选项,它们在Google地图中列出.

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:

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

更多推荐

我的Directions API请求无效,为什么?

本文发布于:2023-11-17 15:40:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1610270.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Directions   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!