【问题标题】:Launch Android Google Maps in directions mode, with "Avoid Highways"以方向模式启动 Android 谷歌地图,并带有“避开高速公路”
【发布时间】:2016-11-16 21:32:16
【问题描述】:

在我的 Android 应用中,我尝试在路线模式下启动 Google 地图,并选择了“避开高速公路”。

使用此代码,我可以通过“Avoid Highways”以转弯模式启动 Gmap:

public void openMapsApp(String destinationCoords)
{
    Uri gmmIntentUri = Uri.parse("google.navigation:q="+destinationCoords+"&avoid=h");
    Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
    startActivity(mapIntent);
}

但是,我想在方向模式下启动 Gmaps,而不是逐步导航模式。我想这样做是因为我希望用户能够快速更改他们的目的地,而不必先退出导航模式。

在我尝试这样做时,我将一行更改为:

Uri gmmIntentUri = Uri.parse("https://maps.google.com/?saddr=My+location&daddr="+destinationCoords+"&dirflg=h");

这确实会启动 Gmaps 进入方向模式。然而,出于某种奇怪的原因,dirflg=h 停止工作。当我在网络浏览器中打开此 URL 时,它确实将“避免高速公路”设置为 true,但由于某种原因,当我启动 Gmaps 时它没有设置。

更奇怪的是,在我的应用程序中,如果我使用 dirflg=wdirflg=r 等不同的值,它会分别在步行和公交方向上启动 Gmap。只有dirflg=h 不起作用。

有人有什么想法吗?

【问题讨论】:

  • 没关系,我用dirflg=dh解决了它!!!!

标签: android google-maps android-intent directions


【解决方案1】:

没关系,我用dirflg=dh解决了这个问题!!!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多