Skip to content

Instantly share code, notes, and snippets.

@AdrienVH
Last active April 21, 2016 16:34
Show Gist options
  • Save AdrienVH/11289236 to your computer and use it in GitHub Desktop.
Save AdrienVH/11289236 to your computer and use it in GitHub Desktop.
Utiliser Google Maps pour calculer un itinéraire entre deux adresses
/*
Pré-requis : charger la librairie Google Maps :
<script src="https://maps.googleapis.com/maps/api/js?key=...&sensor=false"></script>
*/
// Adresses
var origin = '191 rue Saint-Jacques, Paris';
var destination = '37 bd Romain Rolland, Montrouge';
// Itinéraire
var directionsService = new google.maps.DirectionsService();
directionsService.route({origin:origin, destination:destination, travelMode:google.maps.TravelMode.DRIVING}, function(result, status){
if(status == google.maps.DirectionsStatus.OK)
{
console.log(result);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment