Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an Android equivalent to Google Maps URL scheme for iOS?

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.

like image 381
Arjun Avatar asked Jul 29 '13 04:07

Arjun


People also ask

What is URL scheme in iOS?

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.

Is Google Maps different on iPhone and Android?

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.

What is the URL for Apple Maps?

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.

How do I get Google Maps to open links in the app iPhone?

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.


1 Answers

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:

  1. &dirflg=d = for Driving directions (this is the default mode. leaving it out is the same as putting it in explicityly).
  2. &dirflg=w = for Walking directions
  3. &dirflg=r = for Public transit.
  4. &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:

enter image description hereenter image description here

Note: Credit for the initial discovery of the options

like image 85
Siddharth Lele Avatar answered Oct 04 '22 15:10

Siddharth Lele