Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch Google Maps to show road directions

Tags:

android

adt

How do I launch Google Maps from my own application to show road directions from current position (GPS) to a specified address?

like image 235
jgauffin Avatar asked Nov 29 '22 10:11

jgauffin


2 Answers

This intent should launch the appropriate Maps Activity with the directions input screen populated with current location and a destination point:

Intent intent = new Intent(Intent.ACTION_VIEW, 
    Uri.parse("http://maps.google.com/maps?f=d&daddr=51.448,-0.972"));
intent.setComponent(new ComponentName("com.google.android.apps.maps", 
    "com.google.android.maps.MapsActivity"));
startActivity(intent);
like image 188
Jeff Gilfelt Avatar answered Dec 06 '22 11:12

Jeff Gilfelt


Uri uri = Uri.parse("geo:40.763500,-73.979305");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent); 

Try it.

like image 44
bastianwegge Avatar answered Dec 06 '22 11:12

bastianwegge