谷歌地图意图 - 避免高速公路和通行费? (机器人)

时间:2013-06-30 03:29:28

标签: android google-maps android-intent

我到处寻找解决方案,却找不到解决办法。基本上我正在尝试启动谷歌地图应用程序,以获得某个地方的行车路线。如何添加避免高速公路和通行费的标志? 我试过将以下内容添加到我的网址中无济于事。 对于高速公路:

&dirflag=h
&avoid=highways

它忽略了我传递给intent的任何参数。我可以在谷歌地图应用程序中进行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));

1 个答案:

答案 0 :(得分: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";