I'm building a website (html / php / javascript / css) with integration with google maps using the JavaScript API.
function initMap() {
var directionsService = new google.maps.DirectionsService;
var directionsDisplay = new google.maps.DirectionsRenderer;
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 11,
center: cidade
});
directionsDisplay.setMap(map);
//Painel texto
calculateAndDisplayRoute(directionsService, directionsDisplay);
directionsDisplay.setPanel(document.getElementById('right-panel'));
}
function calculateAndDisplayRoute(directionsService, directionsDisplay) {
directionsService.route({
origin: document.getElementById('endOrigem').value,
destination: document.getElementById('endDest').value,
waypoints: waypoints,
travelMode: google.maps.TravelMode.DRIVING
}, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
window.alert('ERRO!!');
}
});
}
So far everything is working perfectly. The route opens in a div on the site itself.
What I need is when I go to the site with Android / iOS that Route is opened in the user's Maps, or at least ask the user if he wants to open it on Brownser or Maps.
I do not know how to pass these parameters (source, destination and waypoints ) in the url?!