Jump to content

열지도 문의드립니다.


Recommended Posts

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해서 데이터를 다시 가져오게 했는데도 안나옵니다.

어떻게 해야할까요?

 

 

링크 복사
다른 사이트에 공유하기

안녕하세요.

리액트 코드 대신 Pure JavaScript 으로 작성된 재현 코드 알려주시면 확인해보겠습니다.

(특정 라이브러리에 대한 코드 리뷰는 지원하지 않는 점 참고부탁드립니다.)

감사합니다.

링크 복사
다른 사이트에 공유하기

게시글 및 댓글을 작성하려면 로그인 해주세요.



로그인
×
×
  • Create New...