안녕하세요~
현재 restAPI를 이용해 카테고리 검색을 이용해봤는데 리스폰스 meta 데이터에있는 totalCount에 잡히는 주소들이 어떤 기준으로 잡히는건지 궁금합니다.
const getPoliLine = (
x: number,
y: number,
targetCenterX: number,
targetCenterY: number
) => {
const polyline = new kakao.maps.Polyline({
path: [
[
new kakao.maps.LatLng(x, y),
new kakao.maps.LatLng(targetCenterX, targetCenterY)
]
]
})
const length = structuredClone(polyline.getLength())
polyline.setMap(null)
return Math.round(length)
}
현재 이런식으로 polyline의 getLength를 이용하여 가져온 데이터의 x,y를 이용해 제가 설정한 중심점과 radius를 이용하여
data.forEach((d) => {
const existingIndex = tempSearchResults.findIndex(
(r) => r.id === d.id
)
const length = getPoliLine(
parseFloat(d.x),
parseFloat(d.y),
centerLocation.getLng(),
centerLocation.getLat()
)
if (existingIndex === -1 && length <= searchCondition.targetRadius) {
if (targetCategory) {
tempSearchResults.push({ ...d, category: targetCategory?.label })
}
}
})
이런식으로 ps.categorySearch 콜백안에서 비교하고 있는데 데이터가 잘 맞지않네요.
중심점으로 부터 해당 주소의 거리를 계산하는 방법이 있을까요?? distance를 이용하는 법 말고요.
설명이 부실해서 죄송합니다.