[英]How can I add a source address to google map intent from activity using “google.navigation:ll”?
我想在google.navigation:ll
添加源地址 。 當我使用它時,它顯示從current location
到設置的目的地的導航。 如何為source address
添加參數?
這是我當前的代碼行:
double latitudeDestination = 22.5834881; // or some other location
double longitudeDestination = 88.3078827; // or some other location
String requestedMode = "car"; // or bike or car
String mode = "";
if(requestedMode.equals("walking")) {
mode = "&mode=w";
} else if(requestedMode.equals("bike")) {
mode = "&mode=b";
} else if(requestedMode.equals("car")) {
mode = "&mode=c";
}
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(String.format("google.navigation:ll=%s,%s%s,
latitudeDestination, longitudeDestination, mode)));
startActivity(intent);
注意:我已點擊此鏈接 。
獲取方向和路線的最佳方法是使用Google Maps的Web服務 。 Google Maps Web服務是Google服務的HTTP接口的集合,為您的Maps應用程序提供地理數據。 這些Web服務使用對特定URL的HTTP請求,將URL參數作為參數傳遞給服務。 它將為您提供一切。 我已經在我的應用程序中使用了它。
這是saddr = source address & daddr= destination address
的示例。 您也可以將字符串作為地址而不是lat / lng傳遞。
final Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://maps.google.com/maps?" + "saddr="+ latitude + "," + longitude + "&daddr=" + latitude + "," + longitude));
intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
startActivity(intent);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.