我的 android 应用程序中有很多经纬度。我想知道如何通过 Intent 打开选择器或谷歌地图应用程序并显示从当前位置到该纬度和经度的方向。就像我有 lat=28.605989,lon=77.372970 并且我当前的位置在某个地方所以当我点击按钮时我的应用程序这些经纬度通过 Intent 传递,并将显示从我当前位置到这些经纬度的方向。谢谢。
最佳答案
要将用户长时间导航到目的地,我们可以使用类似这样的东西
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?daddr=28.605989,77.372970"));
startActivity(intent);
在这里。我们只传递目的地经纬度 daddr=28.605989,77.372970
,因此默认情况下,您的当前位置将是源位置。
使用您的网址添加额外信息。
String my_data= String.format(Locale.ENGLISH, "http://maps.google.com/maps?daddr=20.5666,45.345(My Destination Place)");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(my_data));
intent.setPackage("com.google.android.apps.maps");
startActivity(intent);
关于android - 打开 map 以通过 intent-Android 显示当前位置的方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52310436/