2

我到处寻找解决方案,但找不到。基本上我正在尝试启动谷歌地图应用程序以获取某处的行车路线。如何添加标志以避开高速公路和收费站?我尝试将以下内容附加到我的网址无济于事。高速公路:

&dirflag=h
&avoid=highways

它忽略了我传递给意图的任何参数。我可以对谷歌地图应用程序进行 putextra 吗?

这是我的网址:

String url = "http://maps.google.com/maps?saddr=" + mylatitude + "," + 
mylongitude + "&daddr=" + 
anotherlat + "," + anotherlong;
if(somethingischecked) {    
url += AVOID_HIGHWAYS_FLAG?
}                   
Intent toMaps = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
4

1 回答 1

3

您需要使用“dirflg”参数,而不是“dirflag”。

dirflg=h, Avoid highways.
dirflg=t, Avoid tolls.
dirflg=r, Public transit but it only works in some areas.
dirflg=w, Walking but still in beta.
dirflg=b, Biking  but only works in some areas and still in beta.

例如,如果您想避开高速公路:

String url = "http://maps.google.com/maps?saddr=" + lat_A+ "," + lng_B + "&daddr=" + lat_B + "," + lng_B + "&dirflg=h";

如果您想避开高速公路和收费站:

String url = "http://maps.google.com/maps?saddr=" + lat_A+ "," + lng_B + "&daddr=" + lat_B + "," + lng_B + "&dirflg=h,t";
于 2015-06-09T12:48:21.847 回答