php 如何使用谷歌地图 api 将邮政编码转换为地理位置(纬度和经度)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7075912/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to convert postcode to Geolocation (latitude & longitude) using google maps api?
提问by Peeyush
I just want to get latitude & longitude using the post code with Google maps API.
我只想使用带有 Google 地图 API 的邮政编码来获取纬度和经度。
I am using PHP for development.
我正在使用 PHP 进行开发。
How can I do this?
我怎样才能做到这一点?
The post code can be from any where in this world.
邮政编码可以来自世界上的任何地方。
回答by Sanjeev Chauhan
You can do this using google map Geocoding API. Please find below example, but to correct latitude/longitude and address you need to pass full address along with zipcode.
您可以使用谷歌地图地理编码 API 执行此操作。请在下面找到示例,但要更正纬度/经度和地址,您需要传递完整地址和邮政编码。
For more detail please click on below link:
更多详情请点击以下链接:
http://code.google.com/apis/maps/documentation/geocoding/
http://code.google.com/apis/maps/documentation/geocoding/
<?php
$url ="http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false";
$result = simplexml_load_file($url);
print"<pre>";
print_r($result);
?>