Skip to content

Instantly share code, notes, and snippets.

@toin0u
Created January 13, 2013 16:41
Show Gist options
  • Save toin0u/4524977 to your computer and use it in GitHub Desktop.
Save toin0u/4524977 to your computer and use it in GitHub Desktop.
<?php
require 'vendor/autoload.php';
$geocoder = new \Geocoder\Geocoder();
$adapter = new \Geocoder\HttpAdapter\SocketHttpAdapter();
$provider = new \Geocoder\Provider\GoogleMapsProvider($adapter);
$geocoder->registerProvider($provider);
try {
$geocode = $geocoder->geocode('10 rue Gambetta, Paris, France');
var_export($geocode);
} catch (Exception $e) {
echo $e->getMessage();
}
@toin0u
Copy link
Author

toin0u commented Jan 13, 2013

We get:

Could not execute query http://maps.googleapis.com/maps/api/geocode/json?address=10%20rue%20Gambetta%2C%20Paris%2C%20France&sensor=false

But we shoulg get:

Geocoder\Result\Geocoded::__set_state(array(
   'latitude' => 48.8234055,
   'longitude' => 2.3072664,
   'bounds' => 
  array (
    'south' => 48.8234055,
    'west' => 2.3072664,
    'north' => 48.8234055,
    'east' => 2.3072664,
  ),
   'streetNumber' => '10',
   'streetName' => 'Rue Gambetta',
   'cityDistrict' => '14Th Arrondissement Of Paris',
   'city' => 'Paris',
   'zipcode' => '92240',
   'county' => 'Hauts-De-Seine',
   'countyCode' => '92',
   'region' => 'Île-De-France',
   'regionCode' => 'IDF',
   'country' => 'France',
   'countryCode' => 'FR',
   'timezone' => NULL,
))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment