-1
现在我正在使用此代码获取地址:现在我可以从我的网站PHP上的用户获得完整地址吗?
{
"results" : [
{
"address_components" : [
{
"long_name" : "C 2",
"short_name" : "C 2",
"types" : [ "route" ]
},
{
"long_name" : "Tân Bình",
"short_name" : "Tân Bình",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Hồ Chí Minh",
"short_name" : "Hồ Chí Minh",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Việt Nam",
"short_name" : "VN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "C 2, Tân Bình, Hồ Chí Minh, Việt Nam"
...
"status" : "OK"
}
它缺少街道名称:
$url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=$lat,$long&sensor=false";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_ENCODING, "");
$curlData = curl_exec($curl);
curl_close($curl);
$address = json_decode($curlData);
有结果(简体你们可以看到完整的结果在这里:http://maps.googleapis.com/maps/api/geocode/json?latlng=10.8142,106.6438&sensor=false
) 。我想获得更多信息,例如街道名称,门牌号码......我如何获得用户的完整地址?
谢谢你们!
我不认为这个API将能够准确地返回一个给定的拉特/ lng对的房子号码。我只是在英格兰的地址上试过这个地址,并且返回了一系列房屋号码,而不是实际的号码 – RamRaider
@Mit Try'&result_type = street_address'。有关参考资料,请参阅[ReverseGeocoding](https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding) –