fix: 단풍 지도 — 어린이대공원 추가, 지도 가운데 맞춤, +/− 연타 시 반대로 확대되던 문제

This commit is contained in:
minaChoi committed 2026-10-27 10:48:53 +09:00
1 parent 1bfa224c62
commit f4cb2217ed
4 files changed
+23 -6

No files matched your search

+8 -4
View File
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
import { useNavigate, useSearchParams } from 'react-router'
import { cx } from '../lib/utils'
import { ICON_R, LABEL, LABEL_INK, LEAF_SHADOW, MAP_IMG, MAP_SRC, PROVINCE, PROVINCES, labelBoxes, placeProvinces, rankNow, STAGE, headline, md, placeLabels, spread, useFoliage, useLabelSize, type Box, type Kind, type Pt, type Spot, type Stage } from './foliage'
import { ICON_R, LABEL, LABEL_INK, LAND_CX, LEAF_SHADOW, MAP_IMG, MAP_SRC, PROVINCE, PROVINCES, labelBoxes, placeProvinces, rankNow, STAGE, headline, md, placeLabels, spread, useFoliage, useLabelSize, type Box, type Kind, type Pt, type Spot, type Stage } from './foliage'
import { useSheet } from './sheetContext'
import { FoliageMapShare, FoliageSpotShare } from './shareCards'
import { SendIcon } from './svg'
@@ -52,7 +52,7 @@ function Marker({ p, sel }: { p: Pt; sel: boolean }) {
)
}
/** 단풍 지도 페이지: 명소 65곳을 지도에서 확대해 보고 목록으로 고른다. 한 손가락은 확대 전엔 페이지 스크롤, 확대 뒤엔 지도 이동 */
/** 단풍 지도 페이지: 명소 66곳을 지도에서 확대해 보고 목록으로 고른다. 한 손가락은 확대 전엔 페이지 스크롤, 확대 뒤엔 지도 이동 */
export function FoliagePage() {
const navigate = useNavigate()
const [params] = useSearchParams()
@@ -85,8 +85,10 @@ export function FoliagePage() {
const [x0, x1, y0, y1] = [Math.min(...xs), Math.max(...xs), Math.min(...ys), Math.max(...ys)]
// 위쪽은 맨 북쪽 이름표가 잘리지 않게 FIT_TOP 만큼 띄우고, 아래는 제주까지만
const h = H - FIT_TOP - FIT_BOTTOM
const s = Math.min(W / ((x1 - x0 + 0.14) * W), h / ((y1 - y0) * W))
return { s, tx: W / 2 - ((x0 + x1) / 2) * W * s, ty: FIT_TOP + h / 2 - ((y0 + y1) / 2) * W * s }
// 가로는 땅 가운데(LAND_CX)에 맞추되 동·서 끝 명소가 다 들어오게
const half = Math.max(LAND_CX - x0, x1 - LAND_CX) + 0.07
const s = Math.min(W / (2 * half * W), h / ((y1 - y0) * W))
return { s, tx: W / 2 - LAND_CX * W * s, ty: FIT_TOP + h / 2 - ((y0 + y1) / 2) * W * s }
}, [box, spots])
const clamp = useCallback(
@@ -289,6 +291,8 @@ export function FoliagePage() {
drag = null
}
const onDbl = (e: MouseEvent) => {
// +/− 를 빨리 두 번 누른 건 확대로 치지 않는다
if ((e.target as HTMLElement).closest('button')) return
const p = local(e)
zoomAt(2, p.x, p.y, true)
}