简体   繁体   English

如何从Android中的当前位置获取我们在地图中触摸的地方的方向

[英]How to get direction of place wherever we touch in map from current location in Android

I went through lots of links but I am getting confuse about getting direction on Google map. 我经历了很多链接,但我对在Google地图上获取方向感到困惑。 When my apps get start it shows user's current location, and when user click on hospital logo which is on map, it will shows all hospitals within 5 km with user's current location. 当我的应用程序启动时,它会显示用户的当前位置,当用户点击地图上的医院徽标时,它将显示距离用户当前位置5公里范围内的所有医院。 When user click on any places hospital he get information about it. 当用户点击任何地方医院时,他会获得有关它的信息。

Now my point is I want to show direction from current location to hospital which is touched by user. 现在我的观点是我想显示从当前位置到用户感动的医院的方向。 I am using google map API of v2 . 我正在使用API of v2谷歌地图API of v2

Please give me the way through which I can achieve this task... 请告诉我我可以通过哪些方式完成这项任务......

try this 尝试这个

try {
        Intent directioIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr=" + strSourceLatitude  + "," + strSourceLongitude + "&daddr=" + strDestinationLatitude + "," + strDestinationLongitude));
            directioIntent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
            startActivity(directioIntent);
        } catch (Exception e) {
            Utilities.showToast(GetDirectionActivity.this, "Google Map is not installed on your device.");
        }

Checkout this blog post I wrote on painting a Polyline on Google Maps API V2 to draw direction from one location to another: 查看我写的关于在Google Maps API V2上绘制Polyline以在一个位置绘制方向的博客文章:

Google Maps API V2 Directions Google Maps API V2路线

you will find the the relevant methods to get you started. 你会找到相关的方法来帮助你入门。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM