Skip to content

Commit

Permalink
[FE][Fix] #224 : 네이버 지도 샘플 코드 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
effozen committed Nov 21, 2024
1 parent 074b9e1 commit febc9ab
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,7 +5,7 @@ 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 { CanvasWithMap } from '@/component/canvas/CanvasWithMap.tsx';
import { NaverMap } from '@/component/maps/NaverMapSample.tsx';

const contentData = [
{
Expand Down Expand Up @@ -62,7 +62,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 febc9ab

Please sign in to comment.