당신은 정말 구글은 이러한 점에서 작은 스크립트를 발견 한 것은 여러 검사를 루프에 필요하지 실제로 반환 된 데이터는 (PHP에서) 것/루프 읽기에 : 이제
<?php
$data = json_decode(file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?latlng=46.1124,1.245&sensor=true"));
if($data->status == "OK") {
if(count($data->results)) {
foreach($data->results as $result) {
echo $result->formatted_address . "<br />";
}
}
} else {
// error
}
?>
문서를 기반으로이 :
역 지오 코더 이 두 개 이상의 결과를 리턴했습니다. ... 등
그리고 :
는 일반적으로 주소가 적어도 특정에 가장 구체적인에서 반환; 더 정확한 주소는 ... 가장 눈에 띄는 결과 등
당신은 당신이 원하는 (또는 적어도이
$data->results[0]->
검색 무엇을 얻을 수있는 첫 번째 결과 필요
.
그래서의 읽기가 가 types 그 결과 당신이 존재하거나하지하려는 경우 확인 할 수있는 기반 :..
<?php
$data = json_decode(file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?latlng=46.1124,1.245&sensor=true"));
if($data->status == "OK") {
if(count($data->results)) {
foreach($data->results[0]->address_components as $component) {
if(in_array("premise",$component->types) || in_array("route",$component->types) || in_array("park",$component->types)) {
echo $component->long_name . "<br />";
}
}
}
} else {
// error
}
?>
이름은 무엇입니까? 예를 제공해주십시오. – dogbane
예를 들어, Google지도 API에 좌표 "46.1124, 1.245"를 제출 한 후 주소 연관을 반환합니다. API가 나에게이 주소의 상점 이름을 알려주고 싶습니다. 가능한가? 감사. – craymond
반환 결과에서 정보를 추출하려고한다는 것을 의미합니까? – ifaour