我正在创建一个使用谷歌地理编码进行网站注册的网站。目前我使用的代码是服务器端的,但理想情况下我希望将它作为客户端脚本。我如何转换这个:
$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{...
另外,我希望能够过滤掉国家,所以有人知道这个数字代表什么吗?