2017-07-26 77 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

欢迎您。请注意,如果它在某种程度上帮助了你 –

相关问题