Reputation: 9072
I am working on a program that lists directions for errand runners so they know where to drive. It delivers the results on their phone. Every errand runner will be using a Galaxy Samsung Tab 3 with Google Chrome browser. So it is using the mobile version of Google Chrome.
Is it possible to launch Google Maps from a link on a webpage with directions to a clients address and get it started navigating to them?
I did some research into this https://developers.google.com/chrome/mobile/docs/intents and it looks like it might be possible but I'm not sure how to do it or if it will work like I intend?
I also found this (http://developer.android.com/guide/appendix/g-app-intents.html), might help give clues to the answer.
Upvotes: 1
Views: 1781
Reputation: 9072
I recently found a solution. Apparently just linking to google maps on the device will prompt if you want to open with the maps program, which will work for my purposes.
To make it work properly you will want to link to Google Maps using Coordinates.
In javascript my function looks like below
JS:
function getPosition(position){
latitude = position.coords.latitude;
longitude = position.coords.longitude;
var url = 'http://maps.google.com/maps?saddr='+latitude+','+longitude+'&daddr='+navAddress;
window.location.href = url;
}
$("body").on("click",".routemap",function(){
navAddress = $(this).attr("address");
navigator.geolocation.getCurrentPosition(getPosition);//get the current position for google maps linking purposes.
});
Upvotes: 2