如何使用 Intent 打开和定向 Google 地图?

Nic*_*uff 1 android google-maps

我有一个问题让谷歌地图打开后自动播放...

示例:我已经放置了意图代码,是的,它会根据我的纬度和经度打开谷歌地图……但是,我仍然需要按下一个按钮来启动谷歌地图来引导我。如何在没有用户按下的情况下通过意图打开后自动打开谷歌地图?是否可以 ?

这是我的代码,

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);
}
Run Code Online (Sandbox Code Playgroud)

通过 AndroidAndroid 中特定位置的 Intent 从这些开放的 google 地图中获取了一些 Intent 代码信息 - 如何在 android 应用程序中使用特定位置、缩放级别和标记以及来自官方 android 网站https:/ /developer.android.com/guide/components/intents-common.html#Maps

而且,他们没有解释我应该添加什么命令来在打开后自动播放谷歌地图......

希望你能帮助我……非常感谢你的时间和信息

nhp*_*nhp 8

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);
Run Code Online (Sandbox Code Playgroud)