현재 발생되는 이슈는 화면에는 다중 cluster가 보여지나 각각의 클러스터에 customOverlay를 적용할 수 없다는 것입니다.
모든 클러스터에 customOverlay를 지정하고 싶습니다.
// FIXME: 초기화면 => 줌 6, 클러스터
onMount(() => {
mapOption = {
center: new kakao.maps.LatLng(latitude, longitude),
level: INIT_ZOOM_LEVEL,
};
map = new kakao.maps.Map(mapContainer, mapOption);
const getClusterCount = (count: number) => `${count}`;
const styledDongName = `<div class ="mb-20"><span class="text-neutral-900 text-sm font-semibold leading-tight">${dongName}</span></div>`;
clusters = new kakao.maps.MarkerClusterer({
map, // 마커들을 클러스터로 관리하고 표시할 지도 객체
texts: getClusterCount,
averageCenter: true, // 클러스터에 포함된 마커들의 평균 위치를 클러스터 마커 위치로 설정
minLevel: 4, // 클러스터 할 최소 지도 레벨
styles: [
{
display: 'flex',
width: '56px',
height: '56px',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'rgba(12, 12, 12, 0.2)',
borderRadius: '100px',
border: '1px solid rgba(12, 12, 12, 0.7)',
color: 'text-zinc-950',
textAlign: 'center',
fontWeight: 'semi-bold',
},
],
});
const clusterMarkers = cameraList.map(
(camera) =>
new kakao.maps.Marker({
position: new kakao.maps.LatLng(camera.lat, camera.lng),
}),
);
clusters.addMarkers(clusterMarkers);
// FIXME: 위치 수정 필요
// TODO: 다중 Cluster
const clusterPosition = clusters.getMap()?.getCenter() as kakao.maps.LatLng;
console.log(clusterPosition);
if (clusterPosition) {
const customOverlay = new kakao.maps.CustomOverlay({
position: clusterPosition,
content: styledDongName,
});
customOverlay.setMap(map);
}
// FIXME: 줌이 6, 5, 4일 경우에만 노출
// TODO: 생성된 클러스터 위치 위에 content추가 필요
});
</script>