google-maps-api-3 - 使用 Google Maps Distance Matrix API 时是否可以通过多种出行方式

标签 google-maps-api-3 google-distancematrix-api

我需要计算多种出行方式的时间和距离,我尝试传递以 | 分隔的多种出行方式。像这样:

https://maps.googleapis.com/maps/api/distancematrix/json?origins=E149AQ&destinations=UB83PH|NW14SA|WC1E7HU|N78DB&mode=walking|bicycling|driving&language=en-GB&key=myKey
但它不像我预期的那样工作。

最佳答案

每个请求仅支持一种出行模式。要获得多种出行模式的结果,请发出多个请求。
documentation暗示但没有明确说明:
可选参数

mode (defaults to driving) — Specifies the mode of transport to use when calculating distance. Valid values and other request details are specified in the Travel Modes section of this document.


出行方式

For the calculation of distances, you may specify the transportation mode to use. By default, distances are calculated for driving directions. The following travel modes are supported:

  • driving (default) indicates distance calculation using the road network.

  • walking requests distance calculation for walking via pedestrian paths & sidewalks (where available).

  • bicycling requests distance calculation for bicycling via bicycle paths & preferred streets (where available).

  • transit requests distance calculation via public transit routes (where available). This value may only be specified if the request includes an API key or a Google Maps API for Work client ID. If you set the mode to transit you can optionally specify either a departure_time or an arrival_time. If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time). You can also optionally include a transit_mode and/or a transit_routing_preference.

Note: Both walking and bicycling directions may sometimes not include clear pedestrian or bicycling paths, so these directions will return warnings in the returned result which you must display to the user.

关于google-maps-api-3 - 使用 Google Maps Distance Matrix API 时是否可以通过多种出行方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33449938/

相关文章:

javascript - 谷歌地图 API javascript 集成 WordPress

javascript - 我如何让我的谷歌地图指向它应该指向的位置?

python - Google 距离矩阵 API 返回 'ZERO_RESULTS'

google-distancematrix-api - Google Distance Matrix API 调用在特定服务器上不起作用

jquery - 如何使用 jQuery 的 goMaps 插件创建多个标记和自定义信息框

javascript - Google Maps API - 为什么标签不与标记一起动画?

javascript - Google map API - AutoSuggest 表单文本字段

android - 用于谷歌地图距离矩阵服务的 Cordova 插件

ios - 无法在谷歌地图中建立自行车路线

android - 如何通过公交获得覆盖距离