问题描述
我的 android 应用中有很多经纬度.我想知道如何通过意图打开选择器或谷歌地图应用程序并显示从当前位置到该纬度和经度的方向.就像我有 lat=28.605989,lon=77.372970 并且我当前的位置在某处所以当我点击按钮时我的应用程序这些经纬度通过意图,并将显示从我当前位置到这些经纬度的方向.谢谢.
I have many latitude longitude in my android app. I want to know how to open a chooser or Google map App through intent and show direction from current location to that latitude and longitude.Like i have lat=28.605989,lon=77.372970 and my current location is somewhere so when i click on button in my app these lat lon pass through intent and will show direction from my current location to these lat lon. Thank you.
推荐答案
要导航用户到目的地纬度,我们可以使用这样的东西
To navigate user to destination lat long, we can use something like this
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
,因此默认情况下,您的当前位置将是源位置.
Here . we are passing just destination lat long daddr=28.605989,77.372970
, so by default, your current location will be source location.
使用您的网址添加额外信息.
To add extra information with your url .
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);
这篇关于通过 Intent-Android 打开地图以显示从当前位置开始的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!