当使用 Intent 通过 Google map 方向启动导航时,有没有办法指定您想要步行/骑自行车的路线?
最佳答案
参见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
Travel Modes
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:
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.
您可以像这样使用它(代码 fragment 来自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);
关于android - 谷歌地图自行车路线 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28560029/