1

我正在使用以下代碼,以駕駛模式從我的應用打開谷歌地圖。谷歌地圖安卓方向

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

回答

4

可以使用&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); 

谷歌地圖的方向模式:

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

+0

是..的工作...謝謝你..:) – arun