I'm creating a website that uses Google Geocoding for site registration. At the moment the code I'm using is server side but I would ideally like to have this as a client side script. How do I convert this:
$id= mysqli_real_escape_string($con, $_REQUEST["id"]);
$postcode= mysqli_real_escape_string($con, $_REQUEST["postcode"]);
$mapping = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=" . $postcode . "&sensor=false" );
$geocodes = json_decode($mapping);
if($geocodes->status == 'OK'){
$town = $geocodes->results[0]->address_components[1]->long_name;
$city = $geocodes->results[0]->address_components[4]->long_name;
$county = $geocodes->results[0]->address_components[2]->long_name;
$lat = $geocodes->results[0]->geometry->location->lat;
$lon = $geocodes->results[0]->geometry->location->lng;
}
else{...
Also, I'd like to be able to filter out the Country so does anyone know what number represents this?