28

On the iPhone, a maps.google.com URL is intercepted and loaded by the native google maps application. I would like do the same on Android, but Google Maps is being loaded in the browser.

So, in a web page, is it possible to have this url http://maps.google.com/maps?saddr=brighton&daddr=timbuktu open in the Android Google Map application ?

I see from this question that you can do it from another app via an Intent. Can you trigger these Intent's from the browser ?

Edit - On further testing, I've found that the user will be prompted to open the link in browser or map app for standard html links to maps.google.maps :

<a href="http://maps.google.com/maps?saddr=brighton&daddr=timbuktu">show route</a>

I'm having the problem because I'm using javascript to set the window.location.href via a Location API callback (so I can get the user's location and then open the map). I've opened a bug report for this.

Community
  • 1
  • 1
Kevin
  • 11,521
  • 22
  • 81
  • 103
  • Note that since iOS 6, you have to convert all map requests from "maps.google.com" to "maps.apple.com" for the iOS map to activate. Rather annoying really. – Carter Medlin Jan 30 '13 at 00:15
  • There is another question (for Android devices) that is related to this question that I also found helpful. http://stackoverflow.com/questions/8443662/google-maps-link-produces-slightly-moved-marker-when-opened-with-native-iphone-a – Strixy Apr 12 '13 at 22:22

5 Answers5

15

Typing geo:0,0?q=google into the address bar opens the maps activity and searches for google nearby.

I assume this will work from a link in a page, but haven't checked.

a full list of accessible intents here: http://developer.android.com/guide/appendix/g-app-intents.html

Tom Whittock
  • 4,081
  • 19
  • 24
  • Strangely, that isn't working on Nexus One. And even if it did, the geo URI doesn't currently support saddr/daddr parameters. (http://tools.ietf.org/html/draft-mayrhofer-geo-uri-00) – Kevin Jan 10 '11 at 09:41
  • I tested with a link in a page, and it does work on Nexus One (you just can't type it into the URL bar). I any case, I still can't use it for getting directions. – Kevin Jan 10 '11 at 10:08
  • Strange, I can type it into the browser address bar on my HTC. Anyway, in terms of directions, there's the unreliable `google.navigation:q=starbucks` intent, but I hear it's not available everywhere. – Tom Whittock Jan 10 '11 at 13:49
  • Yes, it works on Nexus One with when embedded into hyperlink: Test – Maksym Kozlenko Apr 07 '11 at 07:13
  • Support for this is dismal at best. My research has netted nothing of value, any other ideas out there? – BizLab Oct 17 '13 at 19:05
11

At this moment I use a javascript function that change the following templates:

'urlTemplates': {
            "default": "http://maps.google.com?q={streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
            "ios": "maps:?saddr=Current Location&daddr={streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
            "android": "geo:{streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
            "windows_phone7": "maps:{streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
            "windows_phone8": "bingmaps:?where={streetAddress} {addressLocality} {addressRegion} {postalCode} {addressCountry}",
            "blackberry": "javascript:blackberry.launch.newMap({'address':{'address1':'{streetAddress}','city':'{addressLocality}','country':'{addressCountry}','stateProvince':'{addressRegion}','zipPostal':'{postalCode}'}});"

with what informations I got depending on the device, I do not remember from where I got all the templates and I am sorry for that, and after that I open the the address using window.location.href.

Hope this will help you. Because at the time I need this I spent a lot of time researching it.

Cheesy
  • 339
  • 3
  • 6
7
<html>
  <body>
  <H1>
   <a href="geo:42,2?z=8">Click here for maps</a>
 </h1>
   <BR><BR>
   <a href="geo:53,-9?saddr=(53,-9)&daddr=(42,4)">Click here for route maps</a>
 </body>
</html>

The first click correctly loads the Google App on Android and zooms. In the second click I an trying to replicate a two point route (start address->destination address) and it doesn't seem to work.

barneymc
  • 490
  • 1
  • 5
  • 11
5

I really suffered a lot from this but finally got answer .
Don't use href , it will not work .

For Navigation - window.open("google.navigation:q=23.3728831,85.3372199&mode=d" , '_system');

For Search - window.open("geo:0,0?q=pizza" , '_system');

Read Here - https://developers.google.com/maps/documentation/android/intents

Aditya Raj
  • 168
  • 3
  • 9
0

I'm using this link and it works just fine

<a href='https://www.google.com/maps/place/{{device?.gps_lat}},{{device?.gps_long}}' target="_blank">
Rami Alloush
  • 2,308
  • 2
  • 27
  • 33