自行车的Google Maps Directions意图 [英] Google Maps Directions intent for bicycle

查看:113
本文介绍了自行车的Google Maps Directions意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用意图通过Google Maps Directions启动导航时,是否可以指定您想要步行/骑车的路线?

When using an intent to launch navigation via Google Maps Directions, is there a way to specify you want a route for walking / bicycle?

推荐答案

请参见 https://developers.google.com/maps/documentation/directions/

通过更改模式并避免使用参数,初始请求可以是 进行了修改,以返回风景优美的自行车之旅的路线,从而避免 主要高速公路.

By changing the mode and avoid parameters, the initial request can be modified to return directions for a scenic bicycle journey that avoids major highways.

https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&avoid=highways&mode=bicycling&key=API_KEY

出行方式

计算路线时,可以指定交通方式 使用.默认情况下,将方向计算为行驶方向. 支持以下出行模式:

When you calculate directions, you may specify the transportation mode to use. By default, directions are calculated as driving directions. The following travel modes are supported:

行驶(默认)表示使用道路的标准行驶方向 网络.步行请求通过人行道和道路的步行路线 人行道(如果有).骑车要求骑车路线 通过自行车道和首选街道(如果有).过境 通过公共交通路线(如果有)请求路线.如果 您将模式设置为过境,则可以选择指定 出发时间或到达时间.如果未指定任何时间,则 出发时间默认为现在(即出发时间默认为 到当前时间).您还可以选择包含transit_mode 和/或transit_routing_preference.

driving (default) indicates standard driving directions using the road network. walking requests walking directions via pedestrian paths & sidewalks (where available). bicycling requests bicycling directions via bicycle paths & preferred streets (where available). transit requests directions via public transit routes (where available). 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.

您可以像这样使用它(来自 https://stackoverflow.com/a/2663565/1843331 的代码段 )

You can use it like this (code snippet from https://stackoverflow.com/a/2663565/1843331)

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
    Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"));
startActivity(intent);

这篇关于自行车的Google Maps Directions意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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