【问题标题】:Using Google Transit APIs in android在 Android 中使用 Google Transit API
【发布时间】:2012-10-12 10:40:03
【问题描述】:

我想在 Android 应用程序中使用 Google Transit API。但我正在从服务中获取数据。我使用了以下参数:

http://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&sensor=false&departure_time=1343605500&mode=transit

我总是得到这样的回应:

{
   "routes" : [],
   "status" : "ZERO_RESULTS"
}

我认为我在上述 URL 中使用的任何参数中都传递了错误,也许 departure_time 是错误的?

谁能告诉我们应该传递什么参数?
谁能帮我找出带有返回值的参数的 URL 吗?

【问题讨论】:

    标签: android google-maps google-api


    【解决方案1】:

    您只需将department_time 参数设置为未来的某个时间(例如几天)。来自here

    请求公交路线时,请务必指定 出发时间或到达时间。请注意,在此示例中 出发时间指定为 2012 年 7 月 30 日上午 09:45。更新 在提交请求之前将参数设置为将来的某个时间点。

    试试http://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&sensor=false&departure_time=1350472557&mode=transit,它有效。

    【讨论】:

    • 你是怎么计算时间的——“1350472557”?什么是实际时间?
    • 它是Unix time。有很多在线转换器。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-25
    相关资源
    最近更新 更多