【问题标题】:open google Maps with given directions (route)打开带有给定方向(路线)的谷歌地图
【发布时间】:2018-06-23 13:27:14
【问题描述】:

Andorid Studio 中是否有办法使用已经给定的路由参数(方向)打开 Google 地图应用程序。就像有许多可能的路线可以到达您的目的地。我想选择或创建自己的目的地路线,然后启动 Google Maps for Navigation。

你能帮帮我吗?

【问题讨论】:

标签: java android google-maps navigation directions


【解决方案1】:

答案来自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")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多