01 Oct Recherche par emplacement – Open Street Map
<?php
$overpass = 'https://www.overpass-api.de/api/interpreter?data=[out:json];
node[amenity=pharmacy](50.82914394480393,4.324493408203125,50.86252762098451,4.379768371582031);out;';
$html = file_get_contents($overpass);
$result = json_decode($html, true);
$data = $result['elements'];
foreach($data as $key => $row) {
echo "Lat : ".$row['lat'].'<br />';
/* ON AFFICHE LAT */
echo "Lon : ".$row['lon'].'<br />';
/* ON AFFICHE LON */
echo 'Name : '.$row['tags']['name'].'<br /><br />';
/* ON AFFICHE LE NOM */
}
?>
Explication : Dans la partie amenity on met, notre recherche
Cette partie (50.82914394480393,4.324493408203125,50.86252762098451,4.379768371582031)
est les coordonnées de la zone sélectionnée dans le site officiel du OSM avec un ordre (LEFT , BOTTOM , RIGHT , TOP )