0

我能够启动谷歌地图意图

Uri location = Uri.parse("geo:0,0");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
startActivity(mapIntent);

如何在驾驶模式下启动意图(没有目的地,除非之前在地图中设置),使其看起来像下面的屏幕截图?

在此处输入图像描述

我尝试了设置mode=driving,但这只是打开了常规地图并选择了“驾驶”选项卡:

 Uri location = Uri.parse("geo:0,0?mode=driving");
4

2 回答 2

6

这将在驾驶模式下启动谷歌地图

    Intent intent = getPackageManager().getLaunchIntentForPackage("com.google.android.apps.maps");
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("google.navigation:/?free=1&mode=d&entry=fnls"));
    startActivity(intent);
于 2017-08-20T23:33:04.403 回答
3

我了解到您想在导航模式下打开 Google 地图应用。为此,您可以使用 Google Maps URLs API 中描述的 URL:

https://developers.google.com/maps/documentation/urls/guide#directions-action

下面的代码应该能搞定,相信你需要提供一个destination参数才能直接开启这个模式

String URL = "https://www.google.com/maps/dir/?api=1&travelmode=driving&dir_action=navigate&destination=Los+Angeles";
Uri location = Uri.parse(URL);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
startActivity(mapIntent);

我希望这有帮助!

于 2017-06-06T15:10:45.300 回答