2013-06-30 60 views
2

我到處尋找解決方案,但無法找到一個。基本上我試圖啓動谷歌地圖應用程序來獲取駕車路線。我如何添加避免高速公路和通行費的標誌? 我已經嘗試追加以下到我的網址無濟於事。 用於高速公路:谷歌地圖意圖 - 避免高速公路和收費? (android)

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

回答

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