export default function orderHeatMap() {
const { bounds, map } = useContext(mapFilterContext);
const { heatMap, date, datePickerType, salesType, orderHeatMapArea } = useContext(filterContext);
const { data, refetch } = useQuery<Item[], Object, Item[], [string, string, any, string, string, number, number, number, number, number]>({
queryKey: ["sales", "heatMap", date, salesType, datePickerType, bounds?._sw.x ?? 0, bounds?._sw.y ?? 0, bounds?._ne.x ?? 0, bounds?._ne.y ?? 0, map?.getZoom() ?? 0],
queryFn: mapBounding,
staleTime: 60 * 1000,
gcTime: 300 * 1000,
enabled: !!bounds && !!map?.getZoom() && !!date && !!orderHeatMapArea
}) as any;
useEffect(() => {
if(orderHeatMapArea) {
refetch();
}
}, [ orderHeatMapArea, refetch ]);
useEffect(() => {
if(map) {
if(heatMap.current) {
heatMap.current.setMap(null);
heatMap.current = null;
}
if(orderHeatMapArea && data) {
const heatMapData = data.order.map((item: any) =>
new naver.maps.LatLng(item.lat, item.lon)
);
const orderHeatmap = new naver.maps.visualization.HeatMap({
map: map,
data: heatMapData,
opacity: 0.4,
radius: 50,
});
console.log("dd");
heatMap.current = orderHeatmap;
}
}
}, [ data, map ]);
return null;
}
안녕하세요.
orderHeatMapArea 여부에따라 해당 컴퍼넌트를 불러서 열지도를 보여주는데 처음 버튼을 눌러 orderHeatMapArea true가 되서 열지도를 만들고
다시 버튼을 눌러 false되서 열지도가 지워지고 다시 버튼을 눌러 true로 바꾸면 로컬에서는 열지도가 나오는데 서버에 올리면 나오지가 않습니다.
콘솔에도 찍히는데 왜 안나오는지.. 지도를 움직이면 나와서 true일때 refetch해서 데이터를 다시 가져오게 했는데도 안나옵니다.
어떻게 해야할까요?