Turn by turn multiple points route navigation Google Maps Intent on Android - 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.

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!

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.
Encoded polylines must be prefixed
with enc: and followed by a colon (:).For example:
waypoints=enc:gfo}EtohhU:
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

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.
Voice navigation possible in google map api?
Turn-by-Turn Navigation for Walking and Driving

Related

What libraries to use for Android Project with maps and routing?

Alongside with my friends I am about to develop an android application. The application will use maps a lot, finding routes, placing markers, drawing predefined routes, stuff like that.
There is this Google Maps APIv2. So I tried it, write some code and looks good. I am able to place markers and draw polylines, however my application will have some predefined routes. One route is set of LatLng points. So I just add these points to PolylineOptions and add it to map. Great, it works.
But these predefined routes will be created in web-based application also using Google Maps APIv2 or similar api/library. Some streets are not straight they are curved so you need to create a lot of LatLng points to get it look nice which is very important. I can do this but I want to put only two LatLng points - at the beginning of the street and at the end.
Here is the image:
On the left, route has only two LatLng points (red dots) and that is desired shape of line. On the right same route with 2 LatLng points gives me route coloured in light blue, and this is what actually happens if I just add polyline to GoogleMap object. In order to create same effect as in left image, I need to create many LatLng (red dots) points which is not appropriate for those who will create these routes. So this leads us to routing problem which can be solved by using Google Directions API. Which solves the problem of drawing routes with less markers. Basically what I understood, this API for directions actually creates a lot of these LatLng points that I draw using for-each loop as seen on right part of picture above. And I need to contact Google Web Service for this so I need to have Internet connection - and this is the problem.
Sometimes internet will not be available hence I need some alternative solution. I've heard of Open Street Maps, but I am not sure how to use it and does it needs internet connection for creating these routes.
Is there any free library that offers offline routing and showing maps offline? Basically all map interactions must be done without use of internet.
But it is understandable if internet connection is needed only for the first run of application as it is needed for Google Maps APIv2, well application crashes until I turn on internet, after which any next run I do not need internet..
A web based application will be made for creating these routes and routes will be created by users for whom we develop this application. And as users can be very annoying they will demand some user-friendly and easy interface for creating routes. Telling them that they need to create 100 to 500 points for each route, and if there is 60-70 routes they will gladly say NO to our application.
Any advice? If it is possible, I can write my own routing algorithm for Google Maps to work offline, I am very skilful at "Algorithms and Data Structures" - any guides/tutorials for this? But I guess this map is just set of tiles, and does not have necessary information for finding route.... So please correct If I am mistaken for anything.
You can use the Scout SDK (provides a free usage quota) as it offers full offline maps, routing & navigation.
Have a look into the open source projects GraphHopper, Mapsforge and OpenScience-VTM which can do routing and/or maps offline. And all use OpenStreetMap data. Other projects exists of course, have a look here and here.
Also have a look into the GraphHopper map matching component which could be interesting for your specific use case and can work offline too.
(Note I'm the author of GraphHopper)
If it is possible, I can write my own routing algorithm for Google Maps to work offline
No you can't, the data is not open nor you can buy the data to my knowledge.
Another option is OsmAnd. The OSM wiki also has some information about OsmAnd and even more information about OSM on Android in general as well as pages about rendering and routing.

Google Map v2 Get Direction Android

Can i get direction between 2 points with using Google Maps v2 in my Android application ?
I found Polyline but i don't want to draw a line between 2 points.
I found a solution which is using Intent. It can solve this problem but it is not useful because this solution is starting another map application and I want to show direction in my application. Can i do this ?
You cannot get directions using just the Google Maps V2 api. You should use the Google Directions API direction request call. This will return the raw direction data in json which would allow you to draw a Polyline for the directions on the map or show the data in any format you would like.
There isn't any method to do it because it envolves several computing that must be done in Google Maps servers (and they don't allow you to do so many without paying if you hold a business).
So, the only way is making a petition to google maps servers as they describe in the Google Maps Api documentation that #Bobbake4 linked. Then, you'll receive several coordinates that you'll use to draw a polyline which represents your route.
Hopefully, someone has already coded everything and shared gently with us here https://stackoverflow.com/a/15643705/1516973
That's absolutely the best answer covering Android Google Maps routing that I've found in Stack Overflow, so thanks to #Akexorcist and #emil-adz for it.

Full implementation of Google Maps Directions Service on My Android App

I have searched for hours on the web for an example of implementing the direccions service on my android app.
I am using the google maps android api 2.
Basically I want the directions from the actual position and a marker position selected by the user.
I want to make clear that I donĀ“t want to launch a web browser or the google maps aplication, I want to implement the service on my own app.
Till now I found some examples about drawing the route on tha map, which are ok
http://wptrafficanalyzer.in/blog/gps-and-google-map-in-android-applications-series/
Get driving directions using Google Maps API v2
so I just miss the indications part of the service so y can show on my own listview with arrows (turn to left , to right , etc).
Thanks for reading my question
I'm not sure what you want. In your second link about Google Map API v2, the data for drawing maps comes from maps.googleapis.com .You can see https://developers.google.com/maps/documentation/directions/ for more documentation about that.
The xml returned from maps.googleapis.com include <html_instructions> tag which contains instruction like turn left or turn right. So you just need to parse that xml and use <html_instructions> tag for information you need on your listview.
I hope this helps.

Is there anyway to simulate google map on android app?

I am doing the project about map navigation. Currently I work fine with the mapview with GPS and singal route directing. But I can not find anyway that, show the all possible choices on the map, like google map on web.
For example I like to search what restaurants are around my area, so I type "Restaurant" in search bar and search it, the map shold display my current position (I have done this) and also show all the possible restaurants that near my area. After that I pick up one restaurant, and the map will draw the route from my position to the restaurant (I have done this too)
I have spent many time search on internet but couldn't find any critical example explain about this, is there any tutorial I can refer to?
Should I use "webview" to directly show the google map web page on app?
I also meet other problem, I use the way below to directe my route on map, it suppose to draw the route on my app, but insted of that the phone will directly oepn google map and drawn the route on google map, am I do this wrong? Is there any better way?
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setData(
Uri.parse("http://maps.google.com/maps?f=d&saddr="
+GeoPointToString(fromGeoPoint)
+"&daddr="
+GeoPointToString(toGeoPoint)
+"&hl=cn")
);
startActivity(intent);
I am the very new beginner of android programming, hope this is not a silly question, wish you can help me. thanks
If you're trying to make an app using Google Maps, you should use the Google Maps API!
https://developers.google.com/maps/documentation/android/
You should be able to download it via your SDK manager in eclipse, or manually install it. I'm using it at work right now, but be wary that you cannot make a commercial app for navigation using these maps.

Android, draw route on google map

In my android project I want to draw route on Google maps. I have coordinates of start and end points. On this points I get km-file from Google web service with points witch across route. For drawing parts of route I use instances of Overlay class. And this solution works, but very slowly. Are there another methods to do that? May be exists ability use built-in Google maps application or any another way?
Right, you can use the built-in google maps application via an intent like this:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"));
startActivity(intent);
see this question for more details
there's a tutorial for using KML here:
http://csie-tw.blogspot.com/2009/06/android-driving-direction-route-path.html
and some sample code here:
How to draw a path on a map using kml file?
it all looks like a lot of overly-complicated hard work - Google should provide API's for this instead.

Categories

Resources