주소를 위경도로 바꾸는 웹 프로그램을 만들었습니다.
그냥 구글 API 가져다 쓰면 되서 매우 간단합니다.
참고해서 사용해 보시기 바랍니다.
위도, 경도
(37.566535, 126.97796919999996)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | <!DOCTYPE html> <html> <head> <title>Geocoding service</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> </head> <!-- 키 값을 입력 해야합니다. --> <body> <style> html, body { height: 700px; margin: 0; padding: 0; } #map { height: 700px; } #floating-panel { top: 10px; left: 25%; z-index: 5; background-color: #fff; padding: 5px; border: 1px solid #999; text-align: center; font-family: 'hanna','Roboto','sans-serif'; line-height: 30px; padding-left: 10px; } </style> <div id="floating-panel"> <input id="address" type="textbox" value="서울"> <input id="submit" type="button" value="주소로 위경도 변환"> <p>위도, 경도 </p> <p id="location_code">(37.566535, 126.97796919999996)</p> </div> <div id="map"></div> <script> function initMap() { var map = new google.maps.Map(document.getElementById('map'), { zoom: 16, center: {lat: 37.566535, lng: 126.97796919999996} }); var geocoder = new google.maps.Geocoder(); document.getElementById('submit').addEventListener('click', function() { geocodeAddress(geocoder, map); }); } function geocodeAddress(geocoder, resultsMap) { var address = document.getElementById('address').value; geocoder.geocode({'address': address}, function(results, status) { if (status === google.maps.GeocoderStatus.OK) { resultsMap.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: resultsMap, position: results[0].geometry.location }); document.getElementById('location_code').innerHTML = results[0].geometry.location; } else { alert('Geocode was not successful for the following reason: ' + status); } }); } </script> <script src="https://maps.googleapis.com/maps/api/js?key='키 값 입력하기'&signed_in=true&callback=initMap" async defer></script> </body> </html> | cs |