title: Google maps - get country, region and city name from longitude and latitude (PHP)
body: <p>I would like to get country, region and city name from longitude and latitude over Google maps API (V3?) - with PHP. I just can't manage to get it for every county, I managed to get this code but it doesn't work on other counties because the returned result is different (the only correct information is country but even that is returned in local name not English name):</p>
  
  <pre><code>&lt;?
      $lok1 = $_REQUEST['lok1'];
      $lok2 = $_REQUEST['lok2'];
  
      $url = 'http://maps.google.com/maps/geo?q='.$lok2.','.$lok1.'&amp;output=json';
      $data = @file_get_contents($url);
      $jsondata = json_decode($data,true);
  
      if(is_array($jsondata )&amp;&amp; $jsondata ['Status']['code']==200)
      {
            $addr = $jsondata ['Placemark'][0]['AddressDetails']['Country']['CountryName'];
            $addr2 = $jsondata ['Placemark'][0]['AddressDetails']['Country']['Locality']['LocalityName'];
            $addr3 = $jsondata ['Placemark'][0]['AddressDetails']['Country']['Locality']['DependentLocality']['DependentLocalityName'];
      }
      echo "Country: " . $addr . " | Region: " . $addr2 . " | City: " . $addr3;
  ?&gt;
  </code></pre>
  
  <p>This works great to get correct data from my country, but not for others...</p>