4

I'm hoping to add a simple one-click solution to a webpage so that android users can click a "navigate now" link which will automatically open a navigation app (google maps for example) so they can navigate easily to that destination.

I have seen this implemented on google searches within the android browser, such as when you search for a business name, but I cant seem to figure it out myself, and confusion with technical terms used in this form of browser-based API has caused me to arrive at a dead end.

Can anyone enlighten me on what I should be searching for, you point me to somewhere I can find the answer?

Any help will be much appreciated.

kirgy
  • 1,567
  • 6
  • 23
  • 39

5 Answers5

7

All you need to do is point the link to a Google Maps URL (i.e. "http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"). The browser should take care of doing what is necessary, as it uses the ACTION_VIEW intent. It will present the user with the option to open in Maps or the Browser, depending on if they have Maps installed.

I think these others answers are assuming you're developing an application, but from what I understand you just want a link on your webpage to invoke Google Maps on Android devices. That being said, all you need to do is what I said above and it should work just fine.

dennisdrew
  • 4,399
  • 1
  • 25
  • 25
  • 1
    Thats brilliant. I was unaware that the browsers held such functionality and that was well explained. Thank you :) – kirgy Oct 03 '12 at 15:03
  • No problem :) just make sure you verify my answer if it works for you! – dennisdrew Oct 03 '12 at 19:20
  • Is there a way to invoke the navigation app installed on the phone (e.g. iGO)? The google maps url worked for me on a Motorola Android phone (invoked Motonav) but now I want iGO to be invoked on LG Optimus 4x HD and Samsung GS 3 and iGO is not in the "complete action using" list. Thanks. – Matjaž Tercelj Feb 26 '13 at 17:35
  • It is up to the developers of those apps to register to receive the broadcast intent of the maps URL, just like the Google Maps app does. It sounds like iGO perhaps doesn't handle the intent. You may want to contact the developers. – dennisdrew Feb 27 '13 at 18:16
  • E-mailed the iGO folks, hoping for an answer. iGO looks a bit too custom in terms of its UI to support GEO intents, though. What would that do? Add a point to the route? Add a favorite? – David Airapetyan Dec 29 '14 at 04:43
  • It's all up to the developers of iGO. They declare in the manifest what intent URI schemes and hosts to listen for (i.e. geo:// scheme, or http://maps.google.com scheme + host), and once they've done that, they can route that to whichever action they like. Let me know if you need more clarification! – dennisdrew Dec 29 '14 at 15:40
2

I would say using google map app for your requirement would be better.
If you still want to stick on browser you can follow following steps.
1. If you are holding lat-longitude value in TextView you can add linify here is the link .
2. You just need to call browser url like this:
http://maps.google.com/?saddr=34.052222,-118.243611&daddr=37.322778,-122.031944 Replace values as per your need.
Thats it.

Good Luck!

Community
  • 1
  • 1
Pratik
  • 831
  • 2
  • 8
  • 13
2

Replace

http://maps.google.com/maps?daddr=37.322778,-122.031944 

with:

google.navigation:q=37.322778,-122.031944
1

You can use something like this:

Uri uri = Uri.parse("http://maps.google.com/maps?saddr=" [userLocation] "&daddr=" [destinationLocation] "&z=" + zoomLevel);
Intent intent = new Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)

Where you can set the user and destination location in the format "lat, lng". and zoomLevel is your desired zoom level.

Joris
  • 1,437
  • 1
  • 15
  • 22
1

well after a lot of link testing I have solved it for me:

<a href="http://maps.google.com/maps?q=loc: <lat>,<lng>&navigate=yes">nav</a>

this one is opening the user nav app choosing menu, and it pass the cords you wish to navigate to.

enjoy

David
  • 633
  • 8
  • 6