2013-11-14 42 views
1

您好我想作一個按鈕,這是該按鈕將啓動谷歌地圖意圖 我目前的位置和目標位置啓動谷歌地圖意圖

如何讓谷歌地圖程序自動檢測我的位置和目標的經度和緯度? 在哪裏我把那個龍和拉特?

我想,地圖直接繪製方向目的地

 final Intent intent = new Intent(Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?" 
+ "saddr="+ current_lat+","+current_longi + "&daddr="+dest_address)); 

intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity"); 

startActivity(intent); 

ALR嘗試這種代碼,但不工作

+0

什麼爲current_lat和代碼current_longi? – Breadbin

+0

我想嘗試,谷歌地圖發現我的位置並進行方向緯度和longitue – user2992573

+0

如果你想谷歌搜索你的位置刪除SADDR(起始地址),並留下剛出目的地址:DADDR =「+ targetLat +」, 「+ targetLang 通過這種方式谷歌地圖開始跟蹤你的位置,跟蹤狂勝......太,你可以設置德SADDR,對你應該有和GPS roadcastrecevier第二趕上你的緯度和經度,設置這些位置到saddr .. –

回答

0

試試這個:

String url = "http://maps.google.com/maps?saddr="+currentLattitude+","+currentLongitude+"&daddr="+targetLat+","+targetLang+"&mode=driving"; 

它應該工作。

+0

所以我把targetLat這個110.39066791534424? – user2992573

+0

如果這是你想要的目標位置的緯度座標 –

+0

仍然有錯誤代碼 – user2992573

5

嘗試使用這些中的一個與景觀意圖:

geo:latitude,longitude 
geo:latitude,longitude?z=zoom 
geo:0,0?q=my+street+address 
geo:0,0?q=business+near+city 

喜歡的東西:

Uri uri = Uri.parse(<ONE OF THE ABOVE STRINGS>); 
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri); 
startActivity(intent); 
0
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
Uri.parse("http://maps.google.com/maps?saddr=srcLatitude,srcLongitude&daddr=destLatitude,destLongitude")); 
startActivity(intent); 


// srcLongitude/Latitude = current Location`s longitude/latitude 

// destLongitude/Latitude = Destination Location`s longitude/latitude