Andorid Studio中是否有一种方法可以使用已给定的用于路由(方向)的参数来打开Google Maps App。就像有很多条到达目的地的路线一样。我想选择或创建自己的到目的地的路线,然后启动Google Maps for Navigation。
能请你帮我吗?
答案 0 :(得分:0)
答案来自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")