Skip to content

Commit

Permalink
Merge pull request #244 from boostcampwm-2024/feature/fe/#224-combineโ€ฆ
Browse files Browse the repository at this point in the history
โ€ฆ-map-and-canvas

[FE][Fix] #224 : ๋„ค์ด๋ฒ„ ์ง€๋„ ์ƒ˜ํ”Œ ์ฝ”๋“œ ์ž‘์„ฑ
  • Loading branch information
happyhyep authored Nov 21, 2024
2 parents caec07c + 1aadab1 commit 8d6f0a2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 25 additions & 0 deletions frontend/src/component/maps/NaverMapSample.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useEffect, useRef } from 'react';
import { setNaverMapSync } from '@/component/maps/naverMapUtils';

export interface INaverMapOptions {
lat: number;
lng: number;
zoom?: number;
}

export const NaverMap = (props: INaverMapOptions) => {
const mapRef = useRef<HTMLDivElement>(null);
const mapOptions: INaverMapOptions = {
lat: props.lat,
lng: props.lng,
zoom: props.zoom,
};

useEffect(() => {
if (mapRef.current) {
setNaverMapSync(mapRef.current, mapOptions);
}
}, []);

return <section ref={mapRef} className="h-full w-full" />;
};
4 changes: 2 additions & 2 deletions frontend/src/pages/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Content } from '@/component/content/Content';
import { MdFormatListBulleted } from 'react-icons/md';
import { FooterContext } from '@/component/layout/footer/LayoutFooterProvider';
import { useNavigate } from 'react-router-dom';
import { NaverMap } from '@/component/maps/NaverMapSample.tsx';
import { buttonActiveType } from '@/component/layout/enumTypes';
import { CanvasWithMap } from '@/component/canvas/CanvasWithMap.tsx';

const contentData = [
{
Expand Down Expand Up @@ -64,7 +64,7 @@ export const Main = () => {
}}
>
{lat && lng ? (
<CanvasWithMap lat={lat} lng={lng} zoom={20} mapType="naver" />
<NaverMap lat={lat} lng={lng} zoom={20} />
) : (
<section className="flex h-full items-center justify-center">
{error ? `Error: ${error}` : 'Loading'}
Expand Down

0 comments on commit 8d6f0a2

Please sign in to comment.