Android - launch google map via web url
Solution 1
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
Solution 2
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.
Solution 3
<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.
Solution 4
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
Related videos on Youtube
Kevin
Updated on July 09, 2022Comments
-
Kevin almost 2 years
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.
-
Carter Medlin over 11 yearsNote 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.
-
Strixy about 11 yearsThere is another question (for Android devices) that is related to this question that I also found helpful. stackoverflow.com/questions/8443662/…
-
-
Kevin over 13 yearsStrangely, that isn't working on Nexus One. And even if it did, the geo URI doesn't currently support saddr/daddr parameters. (tools.ietf.org/html/draft-mayrhofer-geo-uri-00)
-
Kevin over 13 yearsI 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.
-
Tom Whittock over 13 yearsStrange, 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. -
Maksym Kozlenko about 13 yearsYes, it works on Nexus One with when embedded into hyperlink: <a href="geo:50,30">Test</a>
-
BizLab over 10 yearsSupport for this is dismal at best. My research has netted nothing of value, any other ideas out there?