How do I launch Google Maps from my own application to show road directions from current position (GPS) to a specified address?
Asked
Active
Viewed 1.0k times
4
-
1Do you want to use the Maps from Google Maps or do you really want to launch Google Maps on your Mobile device and quit your application? – bastianwegge Apr 21 '11 at 06:56
-
This is what you looking for i think : http://stackoverflow.com/questions/2023669/j2me-android-blackberry-driving-directions-route-between-two-locations/2023685#2023685 – Kartik Domadiya Apr 21 '11 at 06:56
-
I want to launch google maps (and quit my app). I could still use the back button to get back to my app, right? – jgauffin Apr 21 '11 at 07:06
-
possible duplicate of [Launching Google Maps Directions via an intent on Android](http://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android) – jgauffin Apr 21 '11 at 07:19
3 Answers
23
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);

Jeff Gilfelt
- 26,131
- 7
- 48
- 47
-
Jeff, I was wondering if the parser would handle the `&output=kml` parameter? I'm interested in displaying a route with some placemarks that's actually published online as a public map. – Nano Taboada Feb 03 '12 at 18:25
1
Uri uri = Uri.parse("geo:40.763500,-73.979305");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Try it.

bastianwegge
- 2,435
- 1
- 24
- 30
0
For more information:
// Map point based on address
Uri location = Uri.parse("geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+California");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
// Or map point based on latitude/longitude like the answer of @wegginho
Uri location = Uri.parse("geo:37.422219,-122.08364?z=14"); // z param is zoom level

luzielsouza
- 27
- 1
- 6