fix: 단풍 지도를 남한만(백령도·제주·울릉·독도 포함) 정사각형 그림으로, 점마다 산 이름 표시(붙은 곳은 이름 방향 조정)

This commit is contained in:
minaChoi committed 2026-10-21 11:44:10 +09:00
1 parent ab686165a8
commit f182e46e87
2 files changed
+27 -7

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 25 KiB

+27 -7
View File
@@ -7,8 +7,8 @@ import { PostFrame } from './Post'
type Mountain = { name: string; region: string; lat: number; lon: number; peak: string }
type Stage = 'peak' | 'soon' | 'before' | 'after'
// 지도 그림(public/foliage/korea-map.webp, 1024×1536)의 위경도 → 그림 위 위치. generated-images/foliage-map/korea_outline.json 과 같은 값
const MAP = { lon0: 124.0, lon1: 132.2, lat0: 33.0, lat1: 43.1, w: 900, h: 1407, scale: 1.09168, ox: 20.74, cw: 1024, ch: 1536 }
// 지도 그림(public/foliage/korea-map.webp, 정사각형)의 위경도 → 그림 위 위치. generated-images/foliage-map/south_outline.json 과 같은 값
const MAP = { lon0: 124.5, lat1: 38.75, k: 0.809017, s: 153.5327, ox: 40, oy: 62.92, size: 1024 }
const PEAK_DAYS = 3 // 절정일 앞뒤 이만큼은 '지금 절정'
const SOON_DAYS = 7
const SEASON = { from: '09-20', to: '11-25' }
@@ -22,10 +22,27 @@ const STAGE: Record<Stage, { label: string; dot: string }> = {
}
const pos = (m: Mountain) => ({
left: `${((MAP.ox + ((m.lon - MAP.lon0) / (MAP.lon1 - MAP.lon0)) * MAP.w * MAP.scale) / MAP.cw) * 100}%`,
top: `${((((MAP.lat1 - m.lat) / (MAP.lat1 - MAP.lat0)) * MAP.h * MAP.scale) / MAP.ch) * 100}%`,
left: `${((MAP.ox + (m.lon - MAP.lon0) * MAP.k * MAP.s) / MAP.size) * 100}%`,
top: `${((MAP.oy + (MAP.lat1 - m.lat) * MAP.s) / MAP.size) * 100}%`,
})
// 점이 붙은 곳은 이름을 점 왼쪽·위·아래로 돌려 겹치지 않게. 없으면 오른쪽
type Side = 'left' | 'right' | 'top' | 'bottom'
const SIDE: Record<string, Side> = {
광덕산: 'left',
설악산: 'top',
금원산: 'top',
두륜산: 'left',
'한라산(1100도로)': 'left',
}
const LABEL_AT: Record<Side, string> = {
right: 'left-full top-1/2 -translate-y-1/2',
left: 'right-full top-1/2 -translate-y-1/2',
top: 'bottom-full left-1/2 -translate-x-1/2',
bottom: 'top-full left-1/2 -translate-x-1/2',
}
const short = (name: string) => name.replace(/\(.*\)$/, '')
const DAY = 86_400_000
const days = (from: string, to: string) => Math.round((Date.parse(to) - Date.parse(from)) / DAY)
@@ -56,7 +73,7 @@ export function FoliageCard() {
<div className="relative bg-[#e6f2ff] px-4 pt-4 pb-3">
<p className="m-0 text-[13px] font-extrabold opacity-75">단풍 지도 · {md(today)}</p>
<p className="m-0 mt-1 font-jua text-[24px] leading-tight">서울 근교 {seoul.name} 절정 예상 {md(seoul.peak)}</p>
<div className="relative mx-auto mt-2 aspect-[2/3] w-[86%]">
<div className="relative mx-auto mt-1 aspect-square w-full">
<img src="/foliage/korea-map.webp" alt="한반도 지도" className="absolute inset-0 size-full" />
{mountains.map((m) => (
<button
@@ -64,10 +81,13 @@ export function FoliageCard() {
type="button"
onClick={() => setPicked(m.name === picked ? null : m.name)}
aria-label={`${m.name} ${STAGE[m.stage].label}, 절정 예상 ${md(m.peak)}`}
className="absolute -translate-x-1/2 -translate-y-1/2 cursor-pointer p-1.5"
className="absolute -translate-x-1/2 -translate-y-1/2 cursor-pointer p-1"
style={pos(m)}
>
<i className={cx('block size-3.5 rounded-full border-2 border-white shadow-[0_1px_4px_rgb(40_48_74/0.35)]', STAGE[m.stage].dot, m.name === picked && 'size-5')} />
<i className={cx('block size-3 rounded-full border-2 border-white shadow-[0_1px_4px_rgb(40_48_74/0.35)]', STAGE[m.stage].dot, m.name === picked && 'size-4.5')} />
<span className={cx('pointer-events-none absolute text-[10.5px] leading-none font-extrabold whitespace-nowrap text-(--ink2) [text-shadow:0_0_3px_#fff,0_0_3px_#fff]', LABEL_AT[SIDE[m.name] ?? 'right'])}>
{short(m.name)}
</span>
</button>
))}
{sel && (