I have latitude and longutude of two points. I want to show the route between them by opening google maps from my app on button click. How to do so?
Asked
Active
Viewed 485 times
-1
-
1what have you done so far? – V-rund Puro-hit Aug 08 '17 at 08:09
-
MapView seems to not offer simple api methods to do that, but you can get route points through map api : https://stackoverflow.com/questions/13911279/simplest-way-to-draw-a-route-on-mapview – smora Aug 08 '17 at 08:11
-
Possible duplicate of [how to draw path between 2 points on google map](https://stackoverflow.com/questions/21154758/how-to-draw-path-between-2-points-on-google-map) – Rucha Bhatt Joshi Aug 08 '17 at 10:59
2 Answers
0
Use below code for getting show route in google map...
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("
http://maps.google.com/maps?" +"saddr=" + sourcelatLng + "&daddr=" + destlatlng;
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);

Vishal Vaishnav
- 3,346
- 3
- 26
- 57
0
If you want to open maps app with a route from your source to destination, you just need to start an activity with following intent.
Uri routeUri = Uri.parse("http://maps.google.com/maps?saddr=your-lat-1,your-lng-1&daddr=your-lat-2,your-lng-2");
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, routeUri);
startActivity(intent);
Replace your-lat/lng-1/2 with your latitude and longitude.

Siddharth Garg
- 1,560
- 14
- 19