今私はアドレスを取得するため、このコードを使用しています:私のサイトPHPのユーザーから完全なアドレスを取得できますか?
$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
を):あり
{
"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"
}
それは今通りの名がありませんが、 。私は通りの名前、家の番号のようなより多くの情報を得たいと思います...私はどのようにユーザーの完全なアドレスを取得できますか?
ありがとうございます!
私は、このAPIが指定されたlat/lngペアのハウスナンバーを正確に返すことはできないと考えています。私はちょうど家の正確な緯度/経度でイギリスの私の住所のためにこれを試してみました。実際の番号ではなく – RamRaider
@Mit Try&result_type = street_address'より家の番号の範囲を返しました。参照については、[ReverseGeocoding](https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding)を参照してください。 –