打开地图以显示从当前位置到Intent-Android的方向 [英] Open map to show direction from current location through intent-Android

查看:158
本文介绍了打开地图以显示从当前位置到Intent-Android的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的android应用中有许多经度.我想知道如何通过意图打开选择器或Google Map App,并显示从当前位置到该纬度和经度的方向.就像我有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的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆