Skip to content

Instantly share code, notes, and snippets.

@AdrienVH
Last active April 23, 2021 19:50
Show Gist options
  • Save AdrienVH/11288920 to your computer and use it in GitHub Desktop.
Save AdrienVH/11288920 to your computer and use it in GitHub Desktop.
Appeler Google Maps pour calculer un itinéraire entre deux adresses
<?php
$url = 'http://maps.googleapis.com/maps/api/directions/json?';
// Adresses
$origin = '191 rue Saint-Jacques, Paris';
$destination = '37 bd Romain Rolland, Montrouge';
// Itinéraire
$params = http_build_query(array('origin' => $origin, 'destination' => $destination, 'sensor' => 'false'));
$appel_api = file_get_contents($url.$params);
$resultat = json_decode($appel_api);
echo var_export($resultat, true);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment