谷歌地图android方向

时间:2014-01-30 09:35:57

标签: android google-maps android-intent google-maps-android-api-2

使用以下代码通过我的应用程序以驾驶模式打开谷歌地图。

 String url = "http://maps.google.com/maps?f=d&daddr="+latitude+","+longitude+"&mode=driving";
 Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url)); 
 intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
 startActivity(intent);

但Google地图始终显示步行选项,如图所示。有什么方法可以改变这个吗?

enter image description here

1 个答案:

答案 0 :(得分:5)

您可以使用&dirflg=d作为行车路线。

所以,现在你的代码应该是这样的

String url = "http://maps.google.com/maps?f=d&daddr="+latitude+","+longitude+"&dirflg=d";
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url)); 
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);   

Google地图方向模式:

dirflg=r - Switches on "Public Transit" (Railway direction)- only works in some areas.

dirflg=w - Switches to walking directions - still in beta.

dirflg=d - Switches to driving directions

相关问题