Skip to content

Instantly share code, notes, and snippets.

@euskadi31
Created January 23, 2012 20:57
Show Gist options
  • Save euskadi31/beed39d347f1b0fcfb51 to your computer and use it in GitHub Desktop.
Save euskadi31/beed39d347f1b0fcfb51 to your computer and use it in GitHub Desktop.
<?php
$q = 'Toulouse, France';
$result = json_decode(
file_get_contents(
sprintf('http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false', urlencode($q))
),
true
);
print_r($result['results'][0]) . PHP_EOL;
$adapter = new \Geocoder\HttpAdapter\CurlHttpAdapter();
$geocoder = new \Geocoder\Geocoder();
$geocoder->registerProviders(array(
new \Geocoder\Provider\GoogleMapsProvider(
$adapter
)
));
$result = $geocoder->geocode($q);
print_r($result) . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment