var geocoder; var map; // 맵을 활성화 시키는 함수 function initialize() { geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 17, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP, streetViewControl: true } map = new google.maps.Map(document.getElementById("AB_map_api"), myOptions); } // 한글주소를 좌표로 변환하는 함수 function codeAddress() { var address = document.getElementById("AB_map_addr").innerHTML; if (geocoder) { geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location, title: "타이틀" }); var contentString = document.getElementById('AB_map_msg').innerHTML; if (contentString != '') { var infowindow = new google.maps.InfoWindow({ content: contentString}); infowindow.open(map,marker); } } else { alert("Geocode was not successful for the following reason: " + status); } }); } } initialize(); codeAddress();