Skip to content

Commit

Permalink
Chore: 맛집 페이지 아이콘 getSpriteOrigin 함수 제거하고 객체로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
geonwooPark committed May 18, 2024
1 parent 64ab02e commit 95cd110
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
16 changes: 2 additions & 14 deletions app/components/_hot-place/Map/StoreListings/Markers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@
import { useMap } from '@/hooks/store/useMapStore'
import React, { useEffect, useState } from 'react'
import { useRouter } from 'next/navigation'
import { MARKER_SIZE, StoreCategory } from '@/constants'
import { MARKER_SIZE, StoreCategory, spriteOrigin } from '@/constants'
import { HotPlaceListingType } from '@/interfaces/interface'

interface MarkersProps {
hotPlaceListings?: HotPlaceListingType[]
}

const getSpriteOrigin = (category: string) => {
if (category === '한식') return MARKER_SIZE * 0
if (category === '일식') return MARKER_SIZE * 1
if (category === '중식') return MARKER_SIZE * 2
if (category === '양식') return MARKER_SIZE * 3
if (category === '분식') return MARKER_SIZE * 4
if (category === '카페') return MARKER_SIZE * 5
}

export default function Markers({ hotPlaceListings }: MarkersProps) {
const map = useMap()
const router = useRouter()
Expand Down Expand Up @@ -61,10 +52,7 @@ export default function Markers({ hotPlaceListings }: MarkersProps) {
MARKER_SIZE * StoreCategory.length,
MARKER_SIZE,
), // 스프라이트 이미지의 크기
spriteOrigin: new window.kakao.maps.Point(
getSpriteOrigin(category),
0,
),
spriteOrigin: new window.kakao.maps.Point(spriteOrigin[category], 0),
}
const markerImage = new window.kakao.maps.MarkerImage(
imageSrc,
Expand Down
15 changes: 12 additions & 3 deletions app/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ export const PAGE = 1
export const LIMIT = 5

// 맛집
export const INITIAL_CENTER = [37.574187, 126.976882]
export const MARKER_SIZE = 40

export const spriteOrigin: Record<string, number> = {
한식: MARKER_SIZE * 0,
일식: MARKER_SIZE * 1,
중식: MARKER_SIZE * 2,
양식: MARKER_SIZE * 3,
분식: MARKER_SIZE * 4,
카페: MARKER_SIZE * 5,
}

export const StoreCategory = [
{
id: 301,
Expand Down Expand Up @@ -248,9 +260,6 @@ export const GuList = [
},
]

export const INITIAL_CENTER = [37.574187, 126.976882]
export const MARKER_SIZE = 40

// 독서
export const bookCategory = [
{ id: 501, category: '경제/경영' },
Expand Down

0 comments on commit 95cd110

Please sign in to comment.