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

Link to comment
Share on other sites

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++; // }
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.