6

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.

xomena
  • 31,125
  • 6
  • 88
  • 117
Endri
  • 714
  • 13
  • 34

3 Answers3

4

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!

xomena
  • 31,125
  • 6
  • 88
  • 117
  • I upvote this answer as it seems to do what I have asked. However, I am not currently working on Android platform recently, so I cannot try it and I can't mark this as an answer. – Endri Apr 18 '19 at 10:07
1

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

Community
  • 1
  • 1
nicandris
  • 327
  • 3
  • 14
  • 1
    I am not looking for directions. Maybe I wasn't clear in the question but I have all the points of the route. I just want to map my route to google map route to get voice navigation feature of Google Map. Also, some paths of my route may not have road path on google map. – Endri May 08 '16 at 18:16
1

You can try to check this documentation/tutorial on how to use turn by turn directions with the Google Maps API. It uses Google Maps Javascript to provide advanced functionality.

And about voice navigation feature, I think this SO question and link can help you.

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59