// 마커를 담을 배열입니다 var markers = []; var x,y; var mapContainer = document.getElementById('map'), // 지도를 표시할 div mapOption = { center: new kakao.maps.LatLng(35.30132428401928, 126.78503023599897), // 지도의 중심좌표 level: 3 // 지도의 확대 레벨 }; // 지도를 생성합니다 var map = new kakao.maps.Map(mapContainer, mapOption); map.setZoomable(false); map.setDraggable(false); if(position.length == 0){ var geocoder = new kakao.maps.services.Geocoder(); geocoder.addressSearch(area_nm, function(result, status) { // 정상적으로 검색이 완료됐으면 if (status === kakao.maps.services.Status.OK) { var coords = new kakao.maps.LatLng(result[0].y, result[0].x); var marker = new kakao.maps.Marker({ map: map, position: coords }); map.setCenter(coords); } }); }else{ displayPlaces(position); } // 검색 결과 목록과 마커를 표출하는 함수입니다 function displayPlaces(places) { var bounds = new kakao.maps.LatLngBounds(), listStr = ''; // 지도에 표시되고 있는 마커를 제거합니다 removeMarker(); for(var i=0; i' + '
' + '
' + ' '+ title + '
' + '
' + '
' + '
' + ' '+ img +'' + '
' + '
' + '
'+addr+'
' + '
'+tel+'
' + '
' + '
' + '
' + ''; var overlay = new kakao.maps.CustomOverlay({ content: content, map: map, position: position }); // 마커를 클릭했을 때 커스텀 오버레이를 표시합니다 kakao.maps.event.addListener(marker, 'click', function() { $('#wrap_'+idx).removeClass('wrap_off').addClass('wrap_on'); overlay.setMap(map); }); } // 지도 위에 표시되고 있는 마커를 모두 제거합니다 function removeMarker() { for ( var i = 0; i < markers.length; i++ ) { markers[i].setMap(null); } markers = []; } // 버튼 클릭에 따라 지도 확대, 축소 기능을 막거나 풀고 싶은 경우에는 map.setZoomable 함수를 사용합니다 function fn_setZoomable(zoomable) { // 마우스 휠로 지도 확대,축소 가능여부를 설정합니다 map.setZoomable(zoomable); map.setDraggable(zoomable); } // 커스텀 오버레이를 닫기 위해 호출되는 함수입니다 function closeOverlay(num) { $('#wrap_'+num).removeClass('wrap_on').addClass('wrap_off'); }