Jump to content

Lat and Long not being returned from geocoded postcode?!


jarv

Recommended Posts

Hi, My codes does not show any Latitude or Longitude but it did last night when I started writing this code?!

 

$postcode = 'BN113ED';
$response = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($postcode) . '&sensor=true');
$response = json_decode($response);
            
$lat = $response->results[0]->geometry->location->lat;
$long = $response->results[0]->geometry->location->lng;

 

here is the URL that shows the JSON

http://maps.googleapis.com/maps/api/geocode/json?address=bn113ed&sensor=true

I just got this message so hopefully I can geocode more postcodes tomorrow?!

var_dump() results jason response string(137) "{ "error_message" : "You have exceeded your daily request quota for this API.", "results" : [], "status" : "OVER_QUERY_LIMIT" } " jason decoded object(stdClass)#1 (3) { ["error_message"]=> string(56) "You have exceeded your daily request quota for this API." ["results"]=> array(0) { } ["status"]=> string(16) "OVER_QUERY_LIMIT" } lat NULL long NULL // $qr = "SELECT * FROM pubs WHERE rsTown = 'Worthing'"; // // $res= mysql_query($qr); // $i=0; // while($row = mysql_fetch_array($res)) // { // $postcode = $row["rsPostCode"]; // $response = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($postcode) . '&sensor=true'); // $response = json_decode($response); // // $lat = $response->results[0]->geometry->location->lat; // $long = $response->results[0]->geometry->location->lng; // // $qr = "UPDATE pubs SET rsLat='$lat',rsLong='$long' WHERE rsPostCode = '$postcode'"; // // //echo $qr; // $res= mysql_query($qr); // echo $qr; // // $i++; // }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.