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.
URL schema is used as an identifier in launching applications and performing a set of commands in iOS devices. The schema name of a URL is the first part of a URL. (e.g. schemaname:// ). For web pages, the schemas are usually http or https.
Google Maps draws on the same map source for both platforms. It also uses the same data repository for place names and business information. Both versions are capable of using an internal GPS unit or network information to display your current location on a map.
Apple Maps Link Apple's iOS URL handler is maps: but the preferred method is to use https://maps.apple.com/ with the location data. If you use this URL instead, it will open in the Apple Maps app on iOS/macOS or redirect to Google Maps on Windows/Android.
Scroll down to the bottom of the menu and tap Settings. Tap Default apps. Under Navigate from your location, tap Google Maps, then under Navigate between locations, tap Google Maps again.
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:
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:
Driving
directions (this is the default mode. leaving it out is the same as putting it in explicityly).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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With