Skip to content

Instantly share code, notes, and snippets.

@benrolfe
Created July 19, 2012 15:36
Show Gist options
  • Save benrolfe/3144744 to your computer and use it in GitHub Desktop.
Save benrolfe/3144744 to your computer and use it in GitHub Desktop.
Geocode location using Open Street Map
$params = array(
'q' => $location . ',UK',
'format' => 'json',
'countrycodes' => 'gb',
'limit' => '1',
'viewbox' => '-10.94,59.42,2.61,49.92',
'bounded' => '1',
'addressdetails' => '1',
);
$geo = file_get_contents( 'http://nominatim.openstreetmap.org/search/?' . http_build_query( $params ) );
if ( $json = json_decode( $geo ) )
{
return $json[0];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment