지도/로컬 API에 대한 문의게시판입니다.
카카오 지도 polygond을 생성할 때
다른 변수에
이런식으로 담겨져 있는 걸 (만약 저 변수가 arr이라고 친다면)
var polygonpath = [
new kakao.maps.LatLng(arr[0].x, arr[0].y),
new kakao.maps.LatLng(arr[1].x, arr[1].y),
…
.
.
.
];
이런식으로 하려고 하는데 저 배열은 몇각형이냐에 따라 동적으로 바뀌어서 for 문을 돌리거나 map을 돌려서 해결하고 싶은데 무언가 방법이 있을까요?
var polygionpath = arr.map((e) => {
new kakao.maps.LatLng(e.x, e.y)
})
이 방식을 하면 TypeError: Cannot read properties of undefined (reading ‘e’) 이게 떠서 어떻게 해야할지 모르겠습니다ㅠ
console로 new kakao.maps.LatLng(e.x, e.y) 를 찍었을 때 화면입니다.