Google路线API(Transit模式)每个请求只返回一个替代路线 [英] Google Directions API (Transit mode) returns only one alternative route per request

查看:219
本文介绍了Google路线API(Transit模式)每个请求只返回一个替代路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个小应用程序,它在传输模式下调用Google Directions API。它的工作原理 - 尽管如此它只返回一条可能的路线,因此它不会显示其他选项。通常我预计有3-4个选项可供选择。



示例:
http://maps.googleapis.com/maps/api / directions / json?origin = bieberstrasse,+ dusseldorf& destination = norf,+ neuss& sensor = false& mode = transit& departure_time = 1399399424

返回的JSON结构具有期望的路由数组,但此数组始终只有一个元素。我已经在巴西和德国的地址上试过了 - 这个国家没有关系,我只有一条路线。

我错过了一些参数吗?有人可以帮我吗?

解决方案

如果您需要其他路线,请指定请求参数 alternatives = true

< p> a中转&安培; DEPARTURE_TIME = 1399399424\" > http://maps.googleapis.com/maps/api/directions/json?alternatives=true&origin=bieberstrasse,+dusseldorf&destination=norf,+neuss&sensor=false&mode=transit& ; departure_time = 1399399424


I have built an small application which calls the Google Directions API in Transit mode. It works - nevertheless it returns only one possible route, so it shows no alternatives. Usually I expect 3-4 options to choose from.

Example: http://maps.googleapis.com/maps/api/directions/json?origin=bieberstrasse,+dusseldorf&destination=norf,+neuss&sensor=false&mode=transit&departure_time=1399399424

The returned JSON structure has the expected "routes" array, but this array always has only one element. I have tried it with addresses in Brazil and Germany - it doesn't matter the country, I only get one single route.

Did I miss some parameter? Could someone help me with it?

解决方案

If you want alternative routes, specify the request parameter alternatives=true:

http://maps.googleapis.com/maps/api/directions/json?alternatives=true&origin=bieberstrasse,+dusseldorf&destination=norf,+neuss&sensor=false&mode=transit&departure_time=1399399424

这篇关于Google路线API(Transit模式)每个请求只返回一个替代路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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