jarv Posted February 21, 2015 Share Posted February 21, 2015 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 https://forums.phpfreaks.com/topic/294784-lat-and-long-not-being-returned-from-geocoded-postcode/ Share on other sites More sharing options...
Ch0cu3r Posted February 21, 2015 Share Posted February 21, 2015 I see no issue with that code. It returns the the lat and long for me after I add echo "$lat, $long"; What does the following return? printf('<pre>%S</pre>', print_r($response, 1)); Link to comment https://forums.phpfreaks.com/topic/294784-lat-and-long-not-being-returned-from-geocoded-postcode/#findComment-1506351 Share on other sites More sharing options...
QuickOldCar Posted February 21, 2015 Share Posted February 21, 2015 The code works fine for me as well adding echo Is there api usage limits? Link to comment https://forums.phpfreaks.com/topic/294784-lat-and-long-not-being-returned-from-geocoded-postcode/#findComment-1506352 Share on other sites More sharing options...
jarv Posted February 21, 2015 Author Share Posted February 21, 2015 no nothing, and your line of code didn't output anything?! Link to comment https://forums.phpfreaks.com/topic/294784-lat-and-long-not-being-returned-from-geocoded-postcode/#findComment-1506360 Share on other sites More sharing options...
jarv Posted February 21, 2015 Author Share Posted February 21, 2015 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 https://forums.phpfreaks.com/topic/294784-lat-and-long-not-being-returned-from-geocoded-postcode/#findComment-1506361 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.