-
Notifications
You must be signed in to change notification settings - Fork 0
[기능 구현] 카카오맵 API를 활용한 지도 표시 기능 구현 #44
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
Changes from all commits
10f72f9
5c833dd
7693210
86c003c
fc24966
2872d2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,6 @@ dist-ssr | |
| *.njsproj | ||
| *.sln | ||
| *.sw? | ||
|
|
||
| # Environment variables | ||
| .env | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| export * from './layout'; | ||
| export * from './header'; | ||
| export * from './optimized-image'; | ||
| export * from './kakao-map'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { Map, MapMarker, useKakaoLoader } from 'react-kakao-maps-sdk'; | ||
|
|
||
| type Props = { | ||
| lat: number; | ||
| lng: number; | ||
| }; | ||
|
|
||
| export const KakaoMap = ({ lat, lng }: Props) => { | ||
| const [loading, error] = useKakaoLoader({ | ||
| appkey: import.meta.env.VITE_KAKAOMAP_API_KEY, | ||
| libraries: ['clusterer', 'drawing', 'services'], | ||
| }); | ||
|
Comment on lines
+9
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| const center = { | ||
| lat: lat, | ||
| lng: lng, | ||
| }; | ||
|
Comment on lines
+14
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| if (loading) return <div>Loading...</div>; | ||
| if (error) return <div>Error: {error.message}</div>; | ||
|
Comment on lines
+19
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| return ( | ||
| <Map // 지도를 표시할 Container | ||
| id='map' | ||
| center={center} | ||
| className='h-full w-full' | ||
| level={3} // 지도의 확대 레벨 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| > | ||
| <MapMarker position={center} /> | ||
| </Map> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './KakaoMap'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,9 @@ | |
| "baseUrl": ".", | ||
| "paths": { | ||
| "@/*": ["./src/*"] | ||
| } | ||
| }, | ||
|
|
||
| "types": ["kakao.maps.d.ts"] | ||
| }, | ||
| "include": ["src"] | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지도에 표시될 기본 위도와 경도 값이 하드코딩되어 있습니다. 이러한 '매직 넘버'는 코드의 가독성과 유지보수성을 저해할 수 있습니다. 이 값들을
src/features/main/constants.ts와 같은 파일에DEFAULT_MAP_CENTER상수로 정의하고,KakaoMap컴포넌트에 props를 넘길 때 스프레드 연산자를 사용하면 더 간결해집니다.