기본 마커는 값이 잘 나오는데
클러스터에 있는거는 자꾸 전체값을 뿌리는데;; 어떻게 처리해야되나여…?
갯수랑 다른거는 전부 잘 나오는데… context값만 잘 나오면 다 끝나는건데… 뭐가문제인지 모르겠네요,
/<![CDATA[/
/*[# th:each="frc : ${frcsList}"]*/
var position = {
title: /*[[${frc.frcName}]]*/,
content: '<div style="max-width: 200px; padding: 4px 8px 6px;"><span style="display: inline-block; font-size: 14px; font-weight: 700;">' + [[${frc.frcName}]] + '</span><br/><span style="display: inline-block; margin-top: 4px; font-size: 12px; line-height: 1.2;">' + [[${frc.addr}]] + '</span></div>',
// content: html,
latlng: new kakao.maps.LatLng(/*[[${frc.lat}]]*/, /*[[${frc.lon}]]*/)
}
positions.push(position);
// setPosition(/*[[${frc.frcName}]]*/, /*[[${frc.lat}]]*/, /*[[${frc.lon}]]*/);
/*[/]*/
var html = '<div style="max-width: 200px; padding: 4px 8px 6px; overflow-y: scroll; width: auto; height: 300px;">'
/*[# th:each="frc : ${frcsList}"]*/
html += '<div style="border-top: solid 0.5px #e4e4e4; padding: 0px 0px 16px 0px;"><span style="display: inline-block; font-size: 14px; font-weight: 700;">' + [[${frc.frcName}]] + '</span><br/><span style="display: inline-block; margin-top: 4px; font-size: 12px; line-height: 1.2;">' + [[${frc.addr}]] + '</span></div>';
var clusterPosition = {
title: /*[[${frc.frcName}]]*/,
// content: '<div style="max-width: 200px; padding: 4px 8px 6px;"><span style="display: inline-block; font-size: 14px; font-weight: 700;">' + [[${frc.frcName}]] + '</span><br/><span style="display: inline-block; margin-top: 4px; font-size: 12px; line-height: 1.2;">' + [[${frc.addr}]] + '</span></div>',
content: html,
latlng: new kakao.maps.LatLng(/*[[${frc.lat}]]*/, /*[[${frc.lon}]]*/)
}
clusterPositions.push(clusterPosition);
// setPosition(/*[[${frc.frcName}]]*/, /*[[${frc.lat}]]*/, /*[[${frc.lon}]]*/);
/*[/]*/
html = '</div>';
setMarker();
/*]]>*/
function clusterOverListener(map, marker, infowindow) {
return function (cluster) {
let markers = cluster.getMarkers();
var lb = new kakao.maps.LatLngBounds(cluster.getBounds().getSouthWest(), cluster.getBounds().getNorthEast())
cluster.getBounds().getSouthWest(); // 영역의 남서좌표
cluster.getBounds().getNorthEast(); // 영역의 북동좌표
markers.forEach(marker1 => {
let position = marker1.getPosition();
var bounds = cluster.getBounds();
if (lb.contain(position)) {
infowindow.open(map, marker1);
}
});
}
}
var markers = [];
var clusterMarkers = [];
for (var i = 0; i < positions.length; i++) {
// 마커를 생성합니다
var marker = new kakao.maps.Marker({
// map: map, // 마커를 표시할 지도
position: positions[i].latlng, // 마커의 위치
});
// 마커에 표시할 인포윈도우를 생성합니다
var infowindow = new kakao.maps.InfoWindow({
content: positions[i].content // 인포윈도우에 표시할 내용
});
var clusterMarker = new kakao.maps.Marker({
// map: map, // 마커를 표시할 지도
position: clusterPositions[i].latlng, // 마커의 위치
});
// 마커에 표시할 인포윈도우를 생성합니다
var clusterInfowindow = new kakao.maps.InfoWindow({
content: positions[i].content // 인포윈도우에 표시할 내용
});
kakao.maps.event.addListener(marker, 'mouseover', makeOverListener(map, marker, infowindow));
kakao.maps.event.addListener(marker, 'mouseout', makeOutListener(infowindow));
markers.push(marker);
}
kakao.maps.event.addListener(clusterer, 'clusterover', clusterOverListener(map, marker, clusterInfowindow));
kakao.maps.event.addListener(clusterer, 'clusterclick', function (cluster) {
// 현재 지도 레벨에서 1레벨 확대한 레벨
var level = map.getLevel() - 1;
map.setLevel(level, {anchor: cluster.getCenter()});
// 지도를 클릭된 클러스터의 마커의 위치를 기준으로 확대합니다
});
clusterer.addMarkers(markers);
진짜 clusterover 하기 어력네여…