As a part of navigation in my app, I am re-directing my app to Google Maps along with the lats and longs. I have already succeeded in passing the source and destination and making it open in Google Maps directly.
Uri gmmIntentUri = Uri.parse("google.navigation:q=9.883456,78.120150");
Intent mapIntent = new Intent(Intent.ACTION_VIEW,gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
But my question is how do I pass multiple points to Google Maps via intent. Recently Google introduced adding multiple destinations in the mobile version of the Google Map app and I presume that its available in the Google Directions API but I don't want to take the twisted path by integrating Google Directions in my app, I'd rather take the highway to Google Maps.
I have been searching a lot on this topic but all I find is the following but that doesnt work either.
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=st.%20louis,mo&daddr=washington,dc%20to:chicago,il%20to:new%20york,ny"));
startActivity(intent);
The above code works only when we open it in Chrome but I want it to open in Google Maps and even adding a mapIntent.setPackage("com.google.android.apps.maps");
doesn't work but its kinda obvious that the above uri passed is a URL that's available in Google Maps of web version.
Any insights or any ideas on how this can be achieved will be more than welcomed.
P.S: Can this be achieved at all ?????
Contruct URL = https://www.google.co.in/maps/dir/18.6121132,73.707989/18.642344,73.707880/18.652344,73.727880/18.6530132,73.7270
In above URL
source = 18.6121132,73.707989
waypoint1 = 18.642344,73.707880
waypoint2 = 18.652344,73.727880
destination = 18.6530132,73.7270
Call Google Map Intent URI
Uri gmmIntentUri = Uri.parse("https://www.google.co.in/maps/dir/18.6121132,73.707989/18.5,73.7/18.8,73.71");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
I have tested it with multiple way points and it worked for me. I hope this will help others
Note: It works only on latest Android Google Maps application
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With