Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE][Fix] #224 : 네이버 지도 샘플 코드 작성 #244

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading