首页 文章

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

提问于
浏览
0

我经历了很多链接,但我对在Google Map 上获取方向感到困惑 . 当我的应用程序启动时,它会显示用户's current location, and when user click on hospital logo which is on map, it will shows all hospitals within 5 km with user'的当前位置 . 当用户点击任何地方医院时,他会获得有关它的信息 .

现在我的观点是我想显示从当前位置到用户感动的医院的方向 . 我正在使用谷歌 Map API of v2 .

请告诉我我可以通过哪些方式完成这项任务......

2 回答

  • 1

    试试这个

    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.");
            }
    
  • 1

    查看我写的关于在 Google Maps API V2 上绘制 Polyline 的博客文章,以便从一个位置绘制方向到另一个位置:

    Google Maps API V2 Directions

    你会找到相关的方法来帮助你入门 .

相关问题