positionsCnt = positions.length;
if(positionsCnt > 0) {
var bounds = new daum.maps.LatLngBounds();
for (var i = 0; i < positionsCnt; i ++) {
latlng= positions[i].latlng
title= positions[i].title
message= positions[i].message
// 마커 이미지를 생성합니다
displayMarker(map, latlng, title, message);
// LatLngBounds 객체에 좌표를 추가합니다
bounds.extend(latlng);
}
map.setBounds(bounds);
}
// 지도에 마커와 인포윈도우를 표시하는 함수입니다
function displayMarker(map, latlng, title, message) {
// 마커를 생성합니다
var marker = new daum.maps.Marker({
map: map, // 마커를 표시할 지도
position: latlng, // 마커를 표시할 위치
//setClickable: false,
//image : markerImage, // 마커 이미지
title : title // 마커의 타이틀, 마커에 마우스를 올리면 타이틀이 표시됩니다
});
// 인포윈도우를 생성합니다
var infowindow = new daum.maps.InfoWindow({
content : message
});
// 마커에 click 이벤트를 등록합니다
daum.maps.event.addListener(marker, 'click', makeOverListener(map, marker, infowindow));
daum.maps.event.addListener(marker, 'click', makeOutListener(infowindow));
}
// 인포윈도우를 표시하는 클로저를 만드는 함수입니다
function makeOverListener(map, marker, infowindow) {
return function() {
infowindow.open(map, marker);
};
}
// 인포윈도우를 닫는 클로저를 만드는 함수입니다
function makeOutListener(infowindow) {
return function() {
infowindow.close();
};
}
위와 같이 했는데 인포윈도우가 나오지 않고 있습니다.
어떻게 해야 되나요?