aru*_*run 1 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);
Run Code Online (Sandbox Code Playgroud)
但Google地图始终显示行走选项,如图所示.有什么方法可以改变吗?

您可以使用&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);
Run Code Online (Sandbox Code Playgroud)
谷歌地图方向模式:
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
| 归档时间: |
|
| 查看次数: |
3244 次 |
| 最近记录: |