1.1.0 • Published 5 years ago

simple-address-finder-kr v1.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

Intro

This is package is only for Korean.

npm package

With

도로명주소 Open API Kakao Developers Open API

How To Use

npm install simple-address-finder-kr

Step 1. Get address list with specific text
import addressFinder from 'simple-address-finder-kr';

const jusoConfig = {
    url: 'https://www.juso.go.kr/addrlink/addrLinkApi.do', // juso.go.kr's url
    key: 'abc', // this is a key from juso.go.kr
    currentPage: 1, // page, default 1,
    countPerPage: 20, // count of results per page, default 20,
    resultType: 'json' // result type (json / xml)
}

const kakaoConfig = {
    url: 'https://dapi.kakao.com/v2/local/search/address.json', // kakao developer's api url (Local Api)
    key: 'abc', // this is a key from kakao developer
}

const addressFinderHelper = new addressFinder({ jusoConfig }, { kakaoConfig });

async function findAddressList () {
    const data = {
        searchText: '종합운동장',
        page: 1,
    }
    const result = await addressFinderHelper.getAddressList(searchText, page);
    return result;
}

findAddressList();

/*
    result is an Array<Object>.
    and the object is...
    
    {
        admCd: "4115010100",
        bdKdcd: "0",
        bdMgtSn: "4115010100100050024000001",
        bdNm: "",
        buldMnnm: "42",
        buldSlno: "0",
        detBdNmList: "",
        emdNm: "의정부동",
        emdNo: "01",
        engAddr: "42, Hoguk-ro 1351beon-gil, Uijeongbu-si, Gyeonggi-do",
        jibunAddr: "경기도 의정부시 의정부동 5-24",
        liNm: "",
        lnbrMnnm: "5",
        lnbrSlno: "24",
        mtYn: "0",
        rn: "호국로1351번길",
        rnMgtSn: "411504343469",
        roadAddr: "경기도 의정부시 호국로1351번길 42 (의정부동)",
        roadAddrPart1: "경기도 의정부시 호국로1351번길 42",
        roadAddrPart2: " (의정부동)",
        sggNm: "의정부시",
        siNm: "경기도",
        udrtYn: "0",
        zipNo: "11749",
    }...
    
    The object doesn't have Latitude and Longitude.
    So, you can use getLatLngWithAddress method and 'roadAddr' in the object in Step 2
*/
Step 2. Get address object with latitude and longitude
async function getAddress () {
    const data = findAddressList()[0]; // this is for the test
    const result = await addressFinder.getLatLngWithAddress(data);
    return result;
}

getAddress();

/*
    result is an Object.
    
    {
        admCd: "4115010100",
        bdKdcd: "0",
        bdMgtSn: "4115010100100050024000001",
        bdNm: "",
        buldMnnm: "42",
        buldSlno: "0",
        detBdNmList: "",
        emdNm: "의정부동",
        emdNo: "01",
        engAddr: "42, Hoguk-ro 1351beon-gil, Uijeongbu-si, Gyeonggi-do",
        jibunAddr: "경기도 의정부시 의정부동 5-24",
        liNm: "",
        lnbrMnnm: "5",
        lnbrSlno: "24",
        mtYn: "0",
        rn: "호국로1351번길",
        rnMgtSn: "411504343469",
        roadAddr: "경기도 의정부시 호국로1351번길 42 (의정부동)",
        roadAddrPart1: "경기도 의정부시 호국로1351번길 42",
        roadAddrPart2: " (의정부동)",
        sggNm: "의정부시",
        siNm: "경기도",
        udrtYn: "0",
        zipNo: "11749",
        ===== latitude and longitude is added! =====
        lat: xxx.xxxxxxxx
        lng: yy.yyyyyy
    }
*/