简体   繁体   中英

Add waypoints to Google Maps Intent (Android)

Trying to use Google Maps Intent for multiple waypoints but don't know the syntax.

I'm wanting to use a Google maps intent with the syntax that they provided (ie "google.navigation:q=lat, long"). However, I can't seem to find a way to include multiple waypoints. I tried chaining the coordinates with '/'s but that didn't work. Any thoughts or resources? The Android developers site doesn't include anything on this.

I would suggest having a look at the Google Maps URLs API.

https://developers.google.com/maps/documentation/urls/guide

Using this API you can construct navigation URL and specify waypoints in addition to origin and destination.

The sample code snippet might be something like

Uri gmmIntentUri = Uri.parse("https://www.google.com/maps/dir/?api=1&origin=Madrid,Spain&destination=Barcelona,Spain&waypoints=Zaragoza,Spain%7CHuesca,Spain&travelmode=driving&dir_action=navigate");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);    
mapIntent.setPackage("com.google.android.apps.maps"); 
startActivity(mapIntent);

I hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM