8000 주소로 위도 경도 정보를 가져오는 코드 · nicecoding1/php_example@abb7a66 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit abb7a66

Browse files
authored
주소로 위도 경도 정보를 가져오는 코드
입력: 주소 출력: 지번주소, 우편번호, 위도, 경도 * 위도, 경도 값은 WGS-84 좌표계를 사용합니다.
1 parent 2b13092 commit abb7a66

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

address_lat_long_get.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
function get_lat_long($address) {
4+
$apiUrl = "https://address.dawul.co.kr/input_pro.php";
5+
$curl = curl_init();
6+
7+
curl_setopt_array($curl, array(
8+
CURLOPT_URL => $apiUrl,
9+
CURLOPT_SSL_VERIFYPEER => 0,
10+
CURLOPT_SSL_VERIFYHOST => 0,
11+
CURLOPT_RETURNTRANSFER => 1,
12+
CURLOPT_POST => 1,
13+
CURLOPT_POSTFIELDS => 'refine_ty=8&protocol_='.urlencode($address),
14+
CURLOPT_HTTPHEADER => array(
15+
'Content-Type: application/x-www-form-urlencoded'
16+
),
17+
));
18+
19+
20+
$response = curl_exec($curl);
21+
curl_close($curl);
22+
$temp = explode("|", $response);
23+
$arr[0] = $temp[4];
24+
$arr[1] = $temp[3];
25+
26+
//서울특별시 중구 한강대로 405 (봉래동2가, 경부고속철도서울민자역사)|서울특별시 중구 봉래동2가 122-11 |04509|126.969422|37.5562730
27+
/*
28+
서울특별시 중구 한강대로 405 (봉래동2가, 경부고속철도서울민자역사)
29+
서울특별시 중구 봉래동2가 122-11
30+
04509
31+
126.969422
32+
37.5562730
33+
*/
34+
35+
return $arr;
36+
}
37+
38+
$address = "서울 중구 한강대로 405";
39+
$result = get_lat_long($address);
40+
print("주소: ".$address."\n\n");
41+
print("위도: {$result[0]}, 경도: {$result[1]}");
42+
?>

0 commit comments

Comments
 (0)
0