2012-02-16 38 views
2

我有問題,移植Iphone應用程序的一些功能到Android。是從該應用程序調用 基本上iphone谷歌地圖應用程序看起來像這樣Android應用程序調用谷歌地圖與汽車,公共,步行控制

enter image description here

我試圖用這個僞代碼複製類似的行爲

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr="+LAT_POSITION+","+LONG_POSITION+"&daddr="+Lat+","+Lon + "&dirflg=w")); 
startActivity(intent); 

它做什麼它帶來了Android地圖應用這種形式

enter image description here

如此則w母雞我點擊查看地圖,我得到

enter image description here

,然後當我按回兩次我得到這個

enter image description here

我的問題是。

我如何獲得(汽車,公共,步行)控制覆蓋地圖?就像在iPhone應用程序 - 在一個屏幕上(其他元素如果可能的話)

其他問題.. 如何啓用默認顯示地圖? (而不是文本方向,這是發生在Android 2.2 - 我已經與froyo檢查三星Galaxy),在4.0(模擬器)地圖默認顯示,但仍然沒有重疊控制(汽車,公共,步行)。

回答

2

您可以使用setComponent明確地告訴地圖應用使用com.google.android.maps.MapsActivity解決的意圖:

Intent intent = new Intent(Intent.ACTION_VIEW, 
    Uri.parse("http://maps.google.com/maps?saddr=" + LAT_POSITION + "," + LONG_POSITION + 
    "&daddr=" + lat + "," + lon + "&dirflg=w")); 
intent.setComponent(new ComponentName("com.google.android.apps.maps", 
    "com.google.android.maps.MapsActivity")); 
startActivity(intent); 

你應該得到的指示覆蓋,但我不知道它會畫出路線,直到用戶點擊「走」。

當然,這是「非API」,並假定地圖已安裝在設備上,並且Google不會更改MapsActivity的內部包裹或類名稱。

+0

url上有一個「&dirflg = w」標誌,我們還需要點擊「go」按鈕嗎? – tesmojones 2012-07-13 09:29:03

相關問題