Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn by turn multiple points route navigation Google Maps Intent on Android

I am looking for a way to open turn-by-turn navigation on Google Maps. I know that from this google article it can only be defined by start and end points.

First option (preferred):

I haven't find any intent in Google Maps that does exactly what I want. Does anyone know if there is one?

Second option:

I have tried other ways to reach what I want. I have tried to create a custom route on maps.google.com (from desktop browser) and open it from Android device.

The link has the following format

https://www.google.com/maps/dir/37.7851009,-122.4049193/37.7817261,-122.4008209/@37.7815141,-122.4059922,16z/data=!4m19!4m18!1m15!3m4!1m2!1d-122.4055931!2d37.7834466!3s0x808580868ad307fd:0xa75b816ccbe984a0!3m4!1m2!1d-122.4061769!2d37.7812298!3s0x80858086b49a3cfb:0x23f20e98c029217c!3m4!1m2!1d-122.4031591!2d37.7817777!3s0x80858080cb0a7eb1:0xdc77f5df810aebcd!1m0!3e2

Instead of opening turn by turn navigation, it open Google Map Android application with the route displayed on the map. This is the nearest of what I want because there is the button that can show turn-by-turn navigation.

I don't know if it is possible to create link of this type from a collection of (lat,lng) geographical points. I see that data parameter is the one containing the route. Does anyone know how to reach it? If it is possible, I think that I can create links in my Android app to open with Google Maps App. (Actually I haven't tried to put this link manually to my app, but I assume this to work.)

Update: I don't want to find a route from point A (start point) to point B (end point). I have all the route from start to finish in geographical coordinates. So, any solution that is of the form direction from A to B are not solution to my problem.

like image 356
Endri Avatar asked May 08 '16 14:05

Endri


People also ask

How do I redirect a route on Google Maps?

To choose an alternate route, either click on a greyed-out route on the map or click on one of the other routes listed on the left-hand side menu. Note that you can also change routes by clicking on one and dragging it so that the directions will take you via certain roads.


Video Answer


2 Answers

As of 2018, you can open Google Maps app in navigation mode using the Google Maps URLs. Google Maps URLs build a universal, cross-platform URL to launch Google Maps, so you can use them with your intents.

The Google maps URLs in navigation mode support origin, destination and waypoints.

E.g.

String url = "https://www.google.com/maps/dir/?api=1&destination=Madrid,Spain&origin=Barcelona,Spain&waypoints=Zaragoza|Huesca&travelmode=driving&dir_action=navigate";           
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);

I hope this helps!

like image 70
xomena Avatar answered Oct 13 '22 00:10

xomena


This is from the Documentation:

Alternatively, you can supply an encoded set of coordinates using the Encoded Polyline Algorithm. This is particularly useful if you have a large number of waypoints, because the URL is significantly shorter when using an encoded polyline.

  1. Encoded polylines must be prefixed with enc: and followed by a colon (:).For example: waypoints=enc:gfo}EtohhU:
  2. You can also include multiple encoded polylines, separated by the pipe character (|). For example: waypoints=via:enc:wc~oAwquwMdlTxiKtqLyiK:|enc:c~vnAamswMvlTor@tjGi}L:|via:enc:udymA{~bxM: The following URL initiates a Directions request for a route between Boston, MA and Concord, MA with stopovers in Charlestown and Lexington, in that order:

https://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&key=YOUR_API_KEY

Source: https://developers.google.com/maps/documentation/directions/intro#Waypoints

like image 35
nicandris Avatar answered Oct 13 '22 01:10

nicandris