Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Browser intent - opening navigation app with GPS co-ordinates

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.

like image 412
kirgy Avatar asked Dec 12 '22 21:12

kirgy


2 Answers

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.

like image 59
dennisdrew Avatar answered Dec 28 '22 07:12

dennisdrew


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!

like image 35
Pratik Avatar answered Dec 28 '22 05:12

Pratik