Skip to content

Instantly share code, notes, and snippets.

@AdrienVH
Last active August 29, 2015 14:00
Show Gist options
  • Save AdrienVH/11287958 to your computer and use it in GitHub Desktop.
Save AdrienVH/11287958 to your computer and use it in GitHub Desktop.
Appeler Nominatim (OSM) pour géocoder une ou plusieurs adresses
<?php
$url = 'http://nominatim.openstreetmap.org/search?';
// Adresses
$adresses[] = '191 rue Saint-Jacques, Paris';
$adresses[] = 'Parc des Buttes Chaumont, Paris';
$adresses[] = '37 bd Romain Rolland, Montrouge';
// Géocodage
foreach($adresses as $adresse)
{
$params = http_build_query(array('q' => $adresse, 'format' => 'json'));
$appel_api = file_get_contents($url.$params);
$resultats = json_decode($appel_api);
echo var_export($resultats, true);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment