【问题标题】:Google map android direction谷歌地图安卓方向
【发布时间】:2014-01-30 09:35:57
【问题描述】:

我正在使用以下代码从我的应用程序中以驾驶模式打开谷歌地图。

 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);

但谷歌地图总是显示步行选项,如图所示。有什么办法可以改变吗?

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多