2017-07-26 73 views
0

我有一個問題讓谷歌地圖玩自動打開後...如何使用Intent打開和定向Google地圖?

例子:我已經把意圖代碼是的,它會打開谷歌地圖根據我的緯度和經度... 但是,我仍然需要按一個按鈕啓動谷歌地圖來指導我。 如何在沒有用戶按下的情況下打開Goog​​le Map後自動打開Goog​​le Map?可能嗎 ?

這裏是我的代碼,

private void turnOnMap() 
{ 
    String labelMap = "Target"; 
    String geouri = "geo:0,0?q=-6.908572,107.610923(XXI)"; 
    Intent mapInt = new Intent(Intent.ACTION_VIEW, Uri.parse(geouri)); 
    startActivity(mapInt); 
} 

我從這些 open google maps through intent for specific location in androidAndroid - How to launch Google map intent in android app with certain location, zoom level and marker的意圖代碼的一些信息,並從Android官方網站https://developer.android.com/guide/components/intents-common.html#Maps

也最新的URI和,他們沒有解釋我應該添加什麼命令來打開後自動播放谷歌地圖...

希望你能幫助我的傢伙...非常感謝你的喲烏爾時間和信息

+0

怎麼樣[官方文檔(https://developers.google.com/maps/documentation/urls/android-intents#launch_turn-by-turn_navigation)? – Eselfar

+0

也許您應該閱讀[Google地圖網址](https://developers.google.com/maps/documentation/urls/guide#directions-action)。 – xomena

+0

我知道它的夥伴...這裏我們去https://developers.google.com/maps/documentation/urls/android-intents#launch_turn-by-turn_navigation 謝謝@Eselfar您的建議..作品;) 和xomena的更多詳細信息穀歌地圖API –

回答

1
String strUri = "http://maps.google.com/maps?q=loc:" + latitude + "," + longitude + " (" + yourLocationName + ")"; 
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(strUri)); 
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); 
startActivity(intent); 
+0

Thx好友...工作正常,順利 –

+0

歡迎您。請注意,如果它在某種程度上幫助了你 –

相關問題