>  Q&A  >  본문

Maps Google API가 잘못된 좌표를 반환합니다.

<p>이 PHP 함수를 사용하여 좌표를 가져오지만 좌표는 항상 틀립니다. 때로는 가깝고 때로는 올바른 지점에서 멀리 떨어져 있습니다. </p> <pre class="brush:php;toolbar:false;">함수 getCoordinates($address, $city, $postalCode, $region, $province) { $url = 'https://maps.googleapis.com/maps/api/geocode/json?'; $params = 배열( '주소' => urlencode($address), '구성요소' => urlencode("지역:$city|administrative_area:$province"), '키' => '내_키' ); $url .= http_build_query($params); $response = file_get_contents($url); $data = json_decode($response, true); if ($data['status'] === '확인') { $latitude = $data['results'][0]['기하학']['location']['lat']; $longitude = $data['results'][0]['기하학']['위치']['lng']; return array('위도' => $latitude, '경도' => $longitude); } 또 다른 { 거짓을 반환; } }</pre> <p>매개변수를 여러 가지 방법으로 사용해 보았지만 항상 동일한 결과, 즉 좌표가 잘못되었습니다.

테스트 매개변수는 다음과 같습니다.


<pre class="brush:php;toolbar:false;">$address = '두체사 졸란다를 통해' $city = '몬크리벨로' $지방 = 'VC' $우편번호 = '13040'</pre> <p>결과는 위도: 45.0742756, 경도: 7.6613655</p><p>올바른 결과는 위도: 45.3307055, 경도: 7.9960788</p><p><strong>< ; /strong></p>
P粉773659687P粉773659687428일 전415

모든 응답(1)나는 대답할 것이다

  • P粉386318086

    P粉3863180862023-07-27 14:56:55

    죄송합니다. 이 새 버전을 사용한 후에는 좌표가 올바르게 표시됩니다.

    으아악

    회신하다
    0
  • 취소회신하다