screenshot

Simple php class for reverse geo:long lat / address lookup

{

public static function getAddress($lat, $long)
{
$url = “http://nominatim.openstreetmap.org/reverse?format=json&lat=%24lat&lon=%24long&zoom=18&addressdetails=1”;
$json = file_get_contents($url);
$arr = json_decode($json, true);
return ($arr[‘display_name’]);
}
public static function getLongLat($address)
{

$address = str_replace(‘ ‘, ‘+’, $address);
$url = “http://nominatim.openstreetmap.org/search?q“.$address.”&format=json&polygon=1&addressdetails=1”;
$json = file_get_contents($url);
$arr = json_decode($json, true);
return Array(
“longitude” => $arr[0][‘lon’],
“latitude” => $arr[0][‘lat’],
);
}
}

//GEO : Long Lat to address
print_r( GEOInfo::getAddress(25.1002466000, 55.1688383000) );

//GEO : Address to Long / Lat
print_r( GEOInfo::getLongLat(‘135 pilkington avenue, birmingham’) );