【发布时间】:2018-06-23 13:27:14
【问题描述】:
Andorid Studio 中是否有办法使用已经给定的路由参数(方向)打开 Google 地图应用程序。就像有许多可能的路线可以到达您的目的地。我想选择或创建自己的目的地路线,然后启动 Google Maps for Navigation。
你能帮帮我吗?
【问题讨论】:
标签: java android google-maps navigation directions
Andorid Studio 中是否有办法使用已经给定的路由参数(方向)打开 Google 地图应用程序。就像有许多可能的路线可以到达您的目的地。我想选择或创建自己的目的地路线,然后启动 Google Maps for Navigation。
你能帮帮我吗?
【问题讨论】:
标签: java android google-maps navigation directions
答案来自Launching Google Maps Directions via an intent on Android.
Uri.Builder directionsBuilder = new Uri.Builder()
.scheme("https")
.authority("www.google.com")
.appendPath("maps")
.appendPath("dir")
.appendPath("")
.appendQueryParameter("api", "1")
.appendQueryParameter("origin", "28.7041" + "," + "77.1025")
.appendQueryParameter("destination", "18.5204" + "," + "73.8567");
startActivity(new Intent(Intent.ACTION_VIEW, directionsBuilder.build()));
如果您希望原点作为当前位置,请删除以下行:
.appendQueryParameter("origin", "28.7041" + "," + "77.1025")
【讨论】: