사진(exif)의 GPS 정보를 받아와 카카오 맵으로 띄우기 - OhMinsSup/tip-review GitHub Wiki

<div id="map" style="width:320px;height:220px;"> 
    //카카오지도 불러오기, 크기는 본인 자유
    <script>
    document.getElementById("img1").onload = function() { 
    //사진을 불러왔을때 작동하므로 onload 사용함
    EXIF.getData(this, function() {
        var exifLong = EXIF.getTag(this, "GPSLongitude");
        var exifLat = EXIF.getTag(this, "GPSLatitude");
        var exifLongRef = EXIF.getTag(this, "GPSLongitudeRef");
        var exifLatRef = EXIF.getTag(this, "GPSLatitudeRef");
        //계산식 적용이유는 해당라이브러리가 위도경도를 도분초 단위로 출력하기 때문
        if (exifLatRef == "S") {
            var latitude = (exifLat[0]*-1) + (( (exifLat[1]*-60) + (exifLat[2]*-1) ) / 3600);						
        } else {
            var latitude = exifLat[0] + (( (exifLat[1]*60) + exifLat[2] ) / 3600);
        }

        if (exifLongRef == "W") {
            var longitude = (exifLong[0]*-1) + (( (exifLong[1]*-60) + (exifLong[2]*-1) ) / 3600);						
        } else {
            var longitude = exifLong[0] + (( (exifLong[1]*60) + exifLong[2] ) / 3600);
        }

        wtmX = latitude,
        wtmY = longitude;

        var container = document.getElementById('map');
        var options = {
            center: new kakao.maps.LatLng(wtmX, wtmY), //wtmX, wtmY 받아옴
            level: 3
        };

        var map = new kakao.maps.Map(container, options);

        // 마커가 표시될 위치입니다 
        var markerPosition  = new kakao.maps.LatLng(wtmX, wtmY); 

        // 마커를 생성합니다
        var marker = new kakao.maps.Marker({
            position: markerPosition
        });

        // 마커가 지도 위에 표시되도록 설정합니다
        marker.setMap(map);

    })
};

</script>
⚠️ **GitHub.com Fallback** ⚠️