|
야후 좌표 주소 API |
좌표를 주소를 변환 하는 API는 구글이나 야후가 있다. 구글은 하루 제한 쿼리가 2500개 야후는 하루 제한 쿼리가 50000개 이다. 여기서 야후 좌표 주소 API를 사용 |
URL:http://kr.open.gugi.yahoo.com/service/rgc.php |
요청 파라미터
파라미터 |
값 |
설명 |
appid |
문자(필수) |
지도API키(key)값 |
latitude |
수치값(필수) |
WGS84 위도 좌표값 |
longitude |
수치값(필수) |
WGS84 경도 좌표값 |
output |
문자:xml(default),json,php |
리턴 받고자 하는 데이터의 형식 |
callback |
문자 |
JSON데이터를 감싸는 콜백 함수의 이름. 값은 A-Z a-z 0-9 사이의 값이 허용된다. output이 json이 아닌 경우는 결과에 아무런 영향을 끼치지 않는다. |
응답 항목
항목 |
설명 |
Publisher |
배포자이름 |
Error |
0보다 큰 경우 에러가 1가지 이상 존재한다는 의미 0또는 음수 인 경우 성공 |
ErrorMessage |
오류에 대한 상세 메시지 |
Found |
결과물의 개수 |
Country |
국가 이름 |
State |
주 또는 특별/광역시 명칭 |
Country |
시/군 구 명칭 |
town |
읍/면/동 명칭 |
샘플 응답
<?xml version="1.0" encoding="UTF-8" ?> <root> <ResultSet> <head> <publisher>YahooKorea GUGI</publisher> <Error>0</Error> <ErrorMessage>No Error</ErrorMessage> <Found>1</Found> </head> <location> <country>대한민국(Korea)</country> <state>서울특별시</state> <county>강남구</county> <town>역삼1동</town> </location> </ResultSet> </root> |
야후 좌표 주소 api 사용예제 |
private void DoItInsertDetailAddress(ArrayList list) { ArrayList fkaddrlist = new ArrayList(); string q = "http://kr.open.gugi.yahoo.com/service/rgc.php?appid={0}&latitude={1}&longitude={2}&output=xml"; string strquery=string.Empty; string key = textBox3.Text; APIKEY string address; foreach (DetailAddress_Resident al in list) { Thread.Sleep(100); strquery = string.Empty; address = string.Empty; strquery = string.Format(q, key, HttpUtility.UrlEncode(al.Lat, Encoding.GetEncoding("utf-8")), HttpUtility.UrlEncode(al.Lng, Encoding.GetEncoding("utf-8")));
XmlDocument doc = new XmlDocument();
doc.Load(strquery);
XmlNode node = doc.SelectSingleNode("root"); XmlNode n = node.SelectSingleNode("ResultSet"); foreach (XmlNode xl in n.SelectNodes("location")) { address = string.Format(address + xl.SelectSingleNode("country").InnerText + " "); address = string.Format(address + xl.SelectSingleNode("state").InnerText + " "); address = string.Format(address + xl.SelectSingleNode("county").InnerText + " "); address = string.Format(address + xl.SelectSingleNode("town").InnerText);
fkaddrlist.Add(new FkAddr_Resident(al.RdNum, address)); } } db.InsertDetailAddress(fkaddrlist); MessageBox.Show("성공"); }
|
|