Files
o2o-site-AEO/solution/site/src/sections/items/TripMap.tsx
T
minaChoiandClaude Opus 5 00e13bca7f [feat] solution/site,shared: 발행본을 /s/stay 목업에 맞춘다 — 잃어버린 CSS 토큰 복원 + 섹션 마크업 이식
목업(/s/stay)이 참조하는 스타일시트가 서버에서 사라져(404) 그 화면을 기준으로 삼을 수
없었다. 브라우저 캐시에 남아 있던 규칙을 꺼내 레포에 되돌리고, 섹션 마크업을 목업 HTML
에서 그대로 옮겼다. Playwright 대조로 섹션 래퍼·제목 16/17, 안쪽 구조 14/17 일치.

- index.css: --fs-display~--fs-xs(유동 타이포 7) · --section-space · --color-line/muted ·
  .h2 .h3 .panel .paper .measure .border-line .text-muted .divide-line .slider-viewport/track
  ★ 이 토큰이 없던 동안 컴포넌트가 var(--fs-display)를 써도 브라우저가 조용히 무시했다 —
    히어로 제목이 본문 크기로 나오던 원인
- HeroSection: 가운데 → 좌하단. 사진 위에 글자를 한가운데 얹으면 피사체를 정확히 가린다
- AnswerBlock·EssentialInfo·Units·Gallery·Location·Faq·LocalGuide·Weather·About:
  목업 마크업 그대로. embla 를 scroll-snap 으로 바꿔 스크립트 없이도 레일이 밀린다
- FestivalSection(계절 탭) · StorySection(이야기 탭 래퍼) · items/TripMap(OSM 타일 지도) 신설
  ★ 지도는 iframe 이 아니라 타일을 직접 깐다 — iframe 은 핀을 하나밖에 못 찍어
    "어떤 순서로 도는가" 를 그릴 수 없다
- items: itinerary·event·video kind 추가(파서에 없어 payload 까지 실려 오고도 화면에서
  사라지던 것) · Rail 을 slider-viewport/track 으로 · SongsSection 을 턴테이블로
- color.ts: 선 색을 secondary → mix(bg, text, .2). secondary 는 '본문 다음으로 진한
  글자색' 이라 선으로 쓰면 표와 카드가 격자무늬처럼 새까맣게 그어진다
- seo/head.ts: --tpl-texture. 없으면 색만 갱지고 면은 매끈해서 인쇄물로 안 보인다
- seo/verify.ts: unitCode·numberOfRooms 를 화면 대조에서 뺀다
  ★ unitCode 는 ㎡의 ISO 코드로 priceCurrency 와 같은 성격인데 예외에 없었다. 그래서
    room_size 가 있는 사업장은 발행 게이트가 전부 막았다(실측: 가은채 객실 12개).
    stay 는 객실 2개 + room_size 없음이라 우연히 통과했다
- shared: LocalPlace.imageUrl/distanceMeters · FestivalEntry.imageUrl ·
  ItineraryStop 좌표 · TemplateLook.texture · people/chronicle/postcard imageUrl
  ★ 좌표·사진은 모델이 만드는 칸이 아니다. 공식 API 로 조회해 채운다

검증: tsc 통과 · Playwright 대조(목업 CSS 주입) 섹션 래퍼·제목 16/17, 안쪽 14/17.
남은 차이는 데이터 한계다 — people 사진은 위키에 원본이 없고(original:false),
weather.note 는 정적 페이지에 날씨 문장을 박는 문제라 보류.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KP1ykMnWZFtLFpm2mow1Sw
2026-09-08 09:53:19 +09:00

129 lines
4.8 KiB
TypeScript

/**
* 일정 지도 — OpenStreetMap 타일을 직접 깔고 그 위에 번호 핀을 찍는다.
*
* ★ 왜 iframe 이 아닌가
* iframe 임베드는 핀을 하나밖에 못 찍고, 순서(1→2→3)를 그릴 수 없다. 일정에서 중요한 건
* "어디"가 아니라 "어떤 순서로 도는가"라 경로가 보여야 한다.
* ★ 타일은 회색으로 눌러 깐다(`grayscale opacity .55`). 지도가 선명하면 핀과 경로가 묻힌다.
* ★ 핀을 누르면 네이버 길찾기로 간다 — 앞 정거장에서 이 정거장까지. 우리가 경로를
* 계산해 그리지 않는다(지어낸 시간을 그릴 수 없다).
*/
const TILE = 256;
/** 경위도 → Web Mercator 픽셀(줌 z 기준). */
function project(lat: number, lng: number, z: number) {
const n = 2 ** z;
const x = ((lng + 180) / 360) * n * TILE;
const s = Math.sin((lat * Math.PI) / 180);
const y = ((0.5 - Math.log((1 + s) / (1 - s)) / (4 * Math.PI)) * n) * TILE;
return {x, y};
}
export interface TripPoint {
name: string;
latitude: number;
longitude: number;
searchQuery?: string;
}
export function TripMap({points, width = 320, height = 168}: {
points: TripPoint[];
width?: number;
height?: number;
}) {
if (points.length === 0) return null;
const lats = points.map((p) => p.latitude);
const lngs = points.map((p) => p.longitude);
const center = {lat: (Math.min(...lats) + Math.max(...lats)) / 2, lng: (Math.min(...lngs) + Math.max(...lngs)) / 2};
// 모든 점이 상자 안에 들어오는 가장 큰 줌. 한 점뿐이면 동네가 보이는 15로 둔다.
let zoom = 15;
for (let z = 16; z >= 10; z -= 1) {
const xs = points.map((p) => project(p.latitude, p.longitude, z).x);
const ys = points.map((p) => project(p.latitude, p.longitude, z).y);
const w = Math.max(...xs) - Math.min(...xs);
const h = Math.max(...ys) - Math.min(...ys);
if (w <= width - 56 && h <= height - 56) {
zoom = z;
break;
}
}
const c = project(center.lat, center.lng, zoom);
const originX = c.x - width / 2;
const originY = c.y - height / 2;
// 화면을 덮는 타일만 깐다.
const tiles: {x: number; y: number; left: number; top: number}[] = [];
const tx0 = Math.floor(originX / TILE);
const ty0 = Math.floor(originY / TILE);
const tx1 = Math.floor((originX + width) / TILE);
const ty1 = Math.floor((originY + height) / TILE);
for (let tx = tx0; tx <= tx1; tx += 1) {
for (let ty = ty0; ty <= ty1; ty += 1) {
tiles.push({x: tx, y: ty, left: tx * TILE - originX, top: ty * TILE - originY});
}
}
const naverTo = (from: TripPoint | undefined, to: TripPoint) => {
const dest = `${to.longitude},${to.latitude},${encodeURIComponent(to.name)}`;
const start = from ? `${from.longitude},${from.latitude},${encodeURIComponent(from.name)}` : '-';
return `https://map.naver.com/p/directions/${start}/${dest}/-/transit`;
};
return (
<div
className="relative mt-3.5 overflow-hidden border-y"
style={{
height,
borderColor: 'var(--tpl-border, #d6d3d1)',
// ★ 타일이 로드되기 전에도 지도 자리가 비어 보이지 않게 — OSM 육지 색이다.
backgroundColor: '#e8e5df',
}}
aria-label="일정 지도"
>
{tiles.map((tile) => (
<img
key={`${tile.x}-${tile.y}`}
src={`https://tile.openstreetmap.org/${zoom}/${tile.x}/${tile.y}.png`}
alt=""
width={TILE}
height={TILE}
loading="lazy"
decoding="async"
className="pointer-events-none absolute max-w-none"
style={{left: tile.left, top: tile.top, filter: 'grayscale(1) contrast(0.95) opacity(0.55)'}}
/>
))}
{points.map((point, index) => {
const p = project(point.latitude, point.longitude, zoom);
return (
<a
key={`${point.name}-${index}`}
href={naverTo(points[index - 1], point)}
target="_blank"
rel="noopener noreferrer"
title={`${point.name} — 네이버 지도`}
className="absolute grid h-[22px] min-w-[22px] -translate-x-1/2 -translate-y-1/2 place-items-center whitespace-nowrap rounded-full px-1.5 text-[11px] font-bold shadow-sm transition-transform hover:scale-110"
style={{
left: p.x - originX,
top: p.y - originY,
backgroundColor: 'color-mix(in oklab, var(--tpl-accent, #2563eb) 70%, currentColor)',
color: 'var(--tpl-bg, #ffffff)',
border: '1.5px solid var(--tpl-bg, #ffffff)',
}}
>
{index + 1}
</a>
);
})}
<span className="absolute bottom-0.5 right-1 bg-white/70 px-1 text-[9px] leading-tight text-stone-600">
© OpenStreetMap
</span>
</div>
);
}