Communitygithub.com

YepAPI/지도 및 위치 기반 스킬

Mapbox/Leaflet 통합, 지오코딩, 매장 찾기, 마커 클러스터링 및 경로 표시 기능을 제공합니다.

지도 및 위치 기반 스킬란 무엇인가요?

이 스킬은 웹 애플리케이션에서 지도와 위치 기반 기능을 구현하기 위한 종합 가이드입니다. Mapbox GL JS(유료)와 Leaflet(무료 오픈소스) 두 가지 지도 라이브러리를 지원하며, 각각의 React 래퍼인 react-map-gl과 react-leaflet 사용법을 설명합니다. 주소를 좌표로 변환하는 지오코딩(Mapbox Geocoding API 또는 OpenStreetMap Nominatim), 대량의 마커 데이터를 효율적으로 처리하는 클러스터링(supercluster), 사용자 위치 기반 매장 찾기(Haversine 거리 계산), 경로 표시(Mapbox Directions API) 등 실제 서비스에 필요한 핵심 패턴을 코드 예제와 함께 제공합니다. 또한 브라우저 위치 정보 사용 시 권한 거부 처리, 지도 컴포넌트의 지연 로딩 등 실무에서 중요한 고려사항을 포함하고 있습니다. Next.js 환경을 기준으로 하며, 클라이언트 사이드에서만 지도를 렌더링하도록 SSR을 비활성화하는 것이 필수입니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/maps-geolocation

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

지도 및 위치 기반 기능

규칙

  • Mapbox GL JS: 풍부한 대화형 지도 제공 — React 래퍼로 react-map-gl 사용
  • Leaflet: 무료 대안 — React 래퍼로 react-leaflet 사용, 기본 타일에는 API 키 불필요
  • API 키 관리: 클라이언트 사이드 Mapbox용 NEXT_PUBLIC_MAPBOX_TOKEN, 서버 측 비밀은 절대 노출 금지
  • 지오코딩: 주소를 좌표로 변환 — Mapbox Geocoding API 또는 OpenStreetMap Nominatim (무료)
  • 마커 클러스터링: 100개 이상의 대규모 마커 데이터셋에는 supercluster 또는 Mapbox 내장 클러스터링 사용
  • 매장 찾기 패턴: 사용자 위치 지오코딩 → Haversine/PostGIS로 가까운 매장 조회 → 지도에 표시
  • 경로 표시: Mapbox Directions API로 운전/도보 경로 생성 → GeoJSON LineString 레이어로 렌더링
  • 브라우저 위치 정보: navigator.geolocation.getCurrentPosition() 사용 시 권한 거부 상황을 항상 우아하게 처리
  • 지도 컴포넌트 지연 로딩: 지도는 무거우므로 dynamic(() => import("./Map"), { ssr: false }) 사용

패턴

// react-map-gl with Mapbox
import Map, { Marker, NavigationControl } from "react-map-gl";
import "mapbox-gl/dist/mapbox-gl.css";

function StoreMap({ stores }: { stores: Store[] }) {
  return (
    <Map
      initialViewState={{ longitude: -122.4, latitude: 37.8, zoom: 11 }}
      mapboxAccessToken={process.env.NEXT_PUBLIC_MAPBOX_TOKEN}
      mapStyle="mapbox://styles/mapbox/streets-v12"
      style={{ width: "100%", height: 400 }}
    >
      <NavigationControl position="top-right" />
      {stores.map((store) => (
        <Marker key={store.id} longitude={store.lng} latitude={store.lat}>
          <Pin />
        </Marker>
      ))}
    </Map>
  );
}
// Haversine 거리 계산 (근처 검색용)
function haversineDistance(lat1: number, lon1: number, lat2: number, lon2: number): number {
  const R = 6371; // km
  const dLat = ((lat2 - lat1) * Math.PI) / 180;
  const dLon = ((lon2 - lon1) * Math.PI) / 180;
  const a = Math.sin(dLat / 2) ** 2 + Math.cos((lat1 * Math.PI) / 180) * Math.cos((lat2 * Math.PI) / 180) * Math.sin(dLon / 2) ** 2;
  return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
}

피해야 할 사항

  • 지도 컴포넌트를 서버사이드 렌더링(SSR)하지 말 것 — 항상 ssr: false 또는 "use client"로 로드
  • 클러스터링 없이 1000개 이상의 마커를 렌더링하지 말 것 — 성능 저하 발생; supercluster 사용
  • 좌표를 하드코딩하지 말 것 — 빌드 시 또는 필요 시점에 주소를 지오코딩
  • 위치 정보 권한 거부를 무시하지 말 것 — 항상 대체 수단(수동 주소 입력) 제공

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

관련 스킬