How can I start Google Maps at walking mode to a destination? I know how to open in navigation mode. I have not found a way to open it in plain walking mode
You have to add the mode parameter as part of your Directions request. mode is one of the optional request parameters that specifies the mode of transport to use when calculating directions. If no mode is specified, the Google Maps Embed API will show one or more of the most relevant modes for the specified route.
Below is a sample Direction request that returns walking directions from Indianapolis to Chicago. If the parameter &mode=walking was removed, the request will return the directions with most relevant modes instead.
https://www.google.com/maps/embed/v1/directions?key=[YOUR API KEY]&origin=indianapolis&destination=chicago&avoid=tolls|highways&mode=walking
Reference:
https://developers.google.com/maps/documentation/embed/guide
It is really just a case of pushing directions instead of start right after you set the address. Directions gives you a chance to change the vehicle. If you go directly to start you won’t see that option.
Related
I am drawing a polyline on the MapView component from an array of coordinates that I am fetching from my backend server. There is a case when I want the user to open the installed Google Map on their android device with these coordinates and get directions based on that.
I know how to open the Google Map app with a single coordinate, like the following one:
const url = 'geo:37.484847,-122.148386';
Linking.openURL(url);
But, I am not sure (even have no idea if it is possible at all) how would I lunch the Google Map app with a bunch of coordinates and show them as a direction route (blue line).
As an example, If I have 3 points: A, B and C, I want to open the Google Map app and the app should display a direction route made using A to B and B to C.
Just got my answer. Sharing it in case anyone else face the same problem.
We just need to open this url: https://www.google.com/maps/dir/?api=1¶meters with the right parameters. In this case, waypoints. A collection of coordinates need to be passed using the pipe - | operator as the separator. The lat and lon should be separated by a comma.
Google has this documented here: https://developers.google.com/maps/documentation/urls/guide#directions-action
Great. To get the directions by deep linking you need to hit the API with the params as origin and destination . So check this https://www.google.com/maps/dir/?api=1¶meters and in place of params you can replace it with the proper params.
Google has perfectly documented here, google map direction
Hope it helps . feel free for doubts.
This is a simple question.
I know it's possible to request to navigate to a specific place, as shown here.
I know there are also some other APIs for Google Maps (here and here), but I don't see an option to send multiple coordinates, to see the path between them, and navigate between them.
For the Web version, there is the ability for waypoints (example here and here), but not for Android.
Is it possible to do it, via Google Maps, or another app?
Or maybe even in the Google Maps API (within the current app) ?
Since V3 Google Maps Directions API support up to 23 waypoints (excluding the origin and destination) when calculating routes:
https://maps.googleapis.com/maps/api/directions/json?origin=sydney,au&destination=perth,au&waypoints=via:-37.81223%2C144.96254%7Cvia:-34.92788%2C138.60008&key=YOUR_API_KEY
So, you can draw polyline with up to 23 points and send they coords in request.
UPDATE:
Please see this tutorial.
UPDATE 2:
Example opening navigation mode of Google Maps app for route Tel-Aviv to Jerusalem via Kiryat Malakhi, Beit+Guvrin and geopoint (31.696342, 35.011337) via Intent:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("https://www.google.com/maps/dir/?api=1&" +
"origin=3780+St+1,+Tel-Aviv+Yafo,+Israel&destination=Jerusalem,+Israel&travelmode=driving" +
"&waypoints=Kiryat+Malakhi,+Israel%7CBeit+Guvrin,+Israel%7C31.696342, 35.011337"));
startActivity(intent);
Result:
Parameter details here.
I would like to be able to have a Google Maps direction link which, when opened on mobile (Android), would bring up directions in Google Maps using a specified direction type (e.g. bicycle).
Using the old Google Maps URL parameters you can do,
https://www.google.com/maps/preview?saddr=[insert_from_address_here]&daddr=[insert_to_address_here]&dirflg=[insert_mode_here]
but it doesn't work on mobile.
Using the new Google Maps URL parameters you can do,
https://www.google.com/maps/dir/[customer address]/[our address]/am=t/
which does work on mobile but I don't know how to specify direction type.
From the Google Forum itself, try this on your URL if this works.
Car /data=!4m2!4m1!3e0
Bicycling /data=!4m2!4m1!3e1
Walking /data=!4m2!4m1!3e2
Public Transit /data=!4m2!4m1!3e3
Airplane /data=!4m2!4m1!3e4
For example
https://www.google.com/maps/dir/747+Howard+St,+San+Francisco,+CA/55+Music+Concourse+Dr,+San+Francisco,+CA/data=!4m2!4m1!3e3
For more information, juct check the link above and this stackexchange question.
I am making an android app that uses the google maps directions services. I have finished almost all of the app but i have a problem with the directions request. I need that the request will give me a bus route and that there will be no transfers. I know i need to use the transit_mode bus ,and the transit_routing_preference fewer_transfers. but i dont know how to add it to the request. do i need to write &transit_mode=bus&transit_routing_preference=fewer_transfers& ?
i looked everywhere but i still dont know how to add those options to the request.
The Google Maps Directions API uses a simple HTTP interface, you're on the right track setting the transit_mode=bus and transit_routing_preference=fewer_transfers. You'll also need to set mode=transit to activate transit mode.
I think the final URL you're looking for will look like:
https://maps.googleapis.com/maps/api/directions/json?origin=Mountain%20View&destination=1600%20Amphitheatre%20Parkway&mode=transit&transit_mode=bus&transit_routing_preference=fewer_transfers&key=YOUR_API_KEY.
Note - The transit_mode and transit_routing_preference parameters will bias your results, but not guarantee the results will always be a bus route with 0 transfers. You'll need to design your application to handle > 0 transfer bus routes.
I want to open Google Maps in Navigation mode from a mobile web link. This seems easy enough for iOS devices using https://developers.google.com/maps/documentation/ios/urlscheme
Is there an equivalent for Android? All I could find was this: https://developer.android.com/guide/appendix/g-app-intents.html
But that doesn't allow you to specify "transitmode" and the other parameters needed to get directions as far as I can tell.
Actually, a slight modification of the methods described in the iOS Doc would work here too (I tested it before putting it here albeit, in a native app and not a web link).
The parameters necessary for this to work are pretty much the same as with the ones listed in the iOS documentation:
From the iOS Docs:
Parameters:
saddr: Sets the starting point for directions searches. This can be a
latitude,longitude or a query formatted address. If it is a query
string that returns more than one result, the first result will be
selected. If the value is left blank, then the user’s current
location will be used.
daddr: Sets the end point for directions searches. Has the same
format and behavior as saddr.
directionsmode: Method of transportation. Can be set to:
driving, transit, or walking.
They are actually, pretty much the same. They are however, no where to be found in the documents. Also, while the first 2 parameters work the usual way here, the last parameter directionsmode does not work as is. A workaround is however, listed below.
That being said, a simple URL can be constructed that can then be passed as an Uri to an Intent that will then handle the application to be launched (Google Maps if installed and/or list of browsers to choose from)
String mapURL = http://maps.google.com/maps?saddr=-33.9417, 150.9473&daddr=-33.92050, 151.04287&dirflg=d
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(mapURL));
startActivity(intent);
A few variations for the Transit Mode:
&dirflg=d = for Driving directions (this is the default mode. leaving it out is the same as putting it in explicityly).
&dirflg=w = for Walking directions
&dirflg=r = for Public transit.
&dirflg=b = for Biking directions.
That being said, at the time of running these test (I admit I was curious enough to test a little further after seeing this question ;-) ), the modes listed in the Travel Modes section don't seem work!
A little proof of sorts:
Note: Credit for the initial discovery of the options