-1

I have a ListView of locations.when user clicks on the particular location from list view then the route must be shown from current location to the user selected location.

How do i do that?

Pankaj
  • 2,115
  • 2
  • 19
  • 39

2 Answers2

0
  1. You need to fetch the location name on click in listview.
  2. Then you need to get lat and long for the location name selected and also fetch lat and long for your current location.
  3. Then use this code

Code:

Intent intent = new Intent( android.content.Intent.ACTION_VIEW, Uri .parse("maps.google.com/maps?saddr="; + current_latitude + "," + current_longitude + "&daddr=" + Dest_lat + "," + Dest_long));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(intent); 
Andy
  • 49,085
  • 60
  • 166
  • 233
Nikhil Virupakshi
  • 482
  • 2
  • 13
  • 26
  • i tried your solution but i am not getting the route..if there are any examples on this , then please send me the links. – user2392465 Apr 01 '14 at 07:32
0

There's a nice answer in stackoverflow and it works like a charm for me. Please follow this link

Even you can add your own logic to store all locations in custom ListView and then get the directions from your current location to any other location on map.

Community
  • 1
  • 1
Pankaj
  • 2,115
  • 2
  • 19
  • 39