Created
December 31, 2016 17:13
-
-
Save YoonjaeYoo/7b3aa3f1ea9dc9f7f609c540b4714283 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, user-scalable=no"> | |
</head> | |
<body> | |
<style> | |
body { | |
margin: 0; | |
padding: 0; | |
} | |
</style> | |
<script src="http://dmaps.daum.net/map_js_init/postcode.v2.js"></script> | |
<script> | |
new daum.Postcode({ | |
width: "100%", | |
oncomplete: function(data) { | |
// 각 주소의 노출 규칙에 따라 주소를 조합한다. | |
// 내려오는 변수가 값이 없는 경우엔 공백('')값을 가지므로, 이를 참고하여 분기 한다. | |
var fullAddr = data.address; // 최종 주소 변수 | |
var extraAddr = ''; // 조합형 주소 변수 | |
// 기본 주소가 도로명 타입일때 조합한다. | |
if (data.addressType === 'R') { | |
//법정동명이 있을 경우 추가한다. | |
if (data.bname !== '') { | |
extraAddr += data.bname; | |
} | |
// 건물명이 있을 경우 추가한다. | |
if (data.buildingName !== '') { | |
extraAddr += (extraAddr !== '' ? ', ' + data.buildingName : data.buildingName); | |
} | |
// 조합형주소의 유무에 따라 양쪽에 괄호를 추가하여 최종 주소를 만든다. | |
fullAddr += (extraAddr !== '' ? ' (' + extraAddr + ')' : ''); | |
} | |
Android.onFoundZipCode(data.zonecode, fullAddr); | |
} | |
}).embed(document.body); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment