leaflet
Leaflet.jsを使って、地図を使ったWebアプリを作り、場所を示す目印や説明を表示したり、図形を描いたり、位置情報を扱ったり、地図の背景を組み込んだりするなど、インタラクティブな地図を構築するSkill。
📜 元の英語説明(参考)
Build interactive maps with Leaflet.js. Use when a user asks to create map-based applications, add markers and popups, draw shapes, handle geolocation, or integrate tile layers in web applications.
🇯🇵 日本人クリエイター向け解説
Leaflet.jsを使って、地図を使ったWebアプリを作り、場所を示す目印や説明を表示したり、図形を描いたり、位置情報を扱ったり、地図の背景を組み込んだりするなど、インタラクティブな地図を構築するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o leaflet.zip https://jpskill.com/download/15062.zip && unzip -o leaflet.zip && rm leaflet.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15062.zip -OutFile "$d\leaflet.zip"; Expand-Archive "$d\leaflet.zip" -DestinationPath $d -Force; ri "$d\leaflet.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
leaflet.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
leafletフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Leaflet — 軽量オープンソースマップ
概要
あなたは、インタラクティブマップのための軽量オープンソース JavaScript ライブラリである Leaflet の専門家です。OpenStreetMap タイル(無料、API キー不要)、カスタムマーカー、GeoJSON レイヤー、クラスタリング、および react-leaflet を介した React 統合を使用して、マップベースのアプリケーションを構築する開発者を支援します。
指示
React 統合
import { MapContainer, TileLayer, Marker, Popup, GeoJSON, useMap } from "react-leaflet";
import MarkerClusterGroup from "react-leaflet-cluster";
import "leaflet/dist/leaflet.css";
function StoreMap({ stores }) {
return (
<MapContainer center={[40.75, -73.98]} zoom={12}
style={{ height: "100vh", width: "100%" }}>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution='© OpenStreetMap contributors'
/>
{/* Cluster markers when zoomed out */}
<MarkerClusterGroup>
{stores.map((store) => (
<Marker key={store.id} position={[store.lat, store.lng]}>
<Popup>
<h3>{store.name}</h3>
<p>{store.address}</p>
<p>Hours: {store.hours}</p>
</Popup>
</Marker>
))}
</MarkerClusterGroup>
</MapContainer>
);
}
// GeoJSON boundaries (neighborhoods, delivery zones)
function DeliveryZones({ zones }) {
return (
<MapContainer center={[40.75, -73.98]} zoom={11}>
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
<GeoJSON
data={zones}
style={(feature) => ({
fillColor: feature.properties.active ? "#22c55e" : "#ef4444",
weight: 2,
opacity: 0.8,
fillOpacity: 0.3,
})}
onEachFeature={(feature, layer) => {
layer.bindPopup(`
<b>${feature.properties.name}</b><br/>
Orders: ${feature.properties.orderCount}<br/>
Avg delivery: ${feature.properties.avgDeliveryMin} min
`);
}}
/>
</MapContainer>
);
}
カスタムアイコンとコントロール
import L from "leaflet";
// Custom marker icon
const storeIcon = new L.Icon({
iconUrl: "/icons/store-pin.png",
iconSize: [32, 32],
iconAnchor: [16, 32],
popupAnchor: [0, -32],
});
// Custom map control (e.g., "Locate Me" button)
function LocateControl() {
const map = useMap();
return (
<button
className="leaflet-control"
onClick={() => map.locate({ setView: true, maxZoom: 16 })}
>
📍 My Location
</button>
);
}
インストール
npm install leaflet react-leaflet
npm install react-leaflet-cluster # Marker clustering
npm install @types/leaflet # TypeScript types
例
例 1: ユーザーが leaflet のセットアップを依頼
ユーザー: "私のプロジェクトのために leaflet をセットアップするのを手伝ってください"
エージェントは以下を行う必要があります。
- システム要件と前提条件を確認する
- leaflet をインストールまたは構成する
- 初期プロジェクト構造をセットアップする
- セットアップが正しく動作することを確認する
例 2: ユーザーが leaflet で機能を構築することを依頼
ユーザー: "leaflet を使用してダッシュボードを作成してください"
エージェントは以下を行う必要があります。
- コンポーネントまたは構成をスキャフォールドする
- 適切なデータソースに接続する
- 要求された機能を実装する
- 出力をテストおよび検証する
ガイドライン
- 無料タイル — OpenStreetMap タイルを使用する(API キー不要、費用なし)。カスタムスタイルには Mapbox/Stadia に切り替える
- マーカークラスタリング — 100 以上のマーカーには
react-leaflet-clusterを使用する。視覚的な混乱を防ぎ、パフォーマンスを向上させる - 地域用の GeoJSON — 境界、ゾーン、およびポリゴンには GeoJSON レイヤーを使用する。データに基づいて動的にスタイルを設定する
- 遅延ロード — Leaflet CSS と JS は約 40KB です。初期ページロードを改善するために、マップコンポーネントを遅延ロードする
- SSR 互換性 — Leaflet には
windowが必要です。Next.js でdynamic(() => import("./Map"), { ssr: false })を使用する - タイルキャッシュ — サービスワーカーを使用して、PWA でのオフラインサポートのためにマップタイルをキャッシュする
- イベント処理 — クリック、ズーム、移動イベントには
useMapEventsフックを使用する。インタラクティブなエクスペリエンスを構築する - 軽量な代替 — 42KB (gzip 圧縮) で、Leaflet は Mapbox GL JS よりも 5 倍小さいです。3D やカスタムスタイルが不要な場合は Leaflet を選択してください
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Leaflet — Lightweight Open-Source Maps
Overview
You are an expert in Leaflet, the lightweight open-source JavaScript library for interactive maps. You help developers build map-based applications using OpenStreetMap tiles (free, no API key), custom markers, GeoJSON layers, clustering, and React integration via react-leaflet.
Instructions
React Integration
import { MapContainer, TileLayer, Marker, Popup, GeoJSON, useMap } from "react-leaflet";
import MarkerClusterGroup from "react-leaflet-cluster";
import "leaflet/dist/leaflet.css";
function StoreMap({ stores }) {
return (
<MapContainer center={[40.75, -73.98]} zoom={12}
style={{ height: "100vh", width: "100%" }}>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution='© OpenStreetMap contributors'
/>
{/* Cluster markers when zoomed out */}
<MarkerClusterGroup>
{stores.map((store) => (
<Marker key={store.id} position={[store.lat, store.lng]}>
<Popup>
<h3>{store.name}</h3>
<p>{store.address}</p>
<p>Hours: {store.hours}</p>
</Popup>
</Marker>
))}
</MarkerClusterGroup>
</MapContainer>
);
}
// GeoJSON boundaries (neighborhoods, delivery zones)
function DeliveryZones({ zones }) {
return (
<MapContainer center={[40.75, -73.98]} zoom={11}>
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
<GeoJSON
data={zones}
style={(feature) => ({
fillColor: feature.properties.active ? "#22c55e" : "#ef4444",
weight: 2,
opacity: 0.8,
fillOpacity: 0.3,
})}
onEachFeature={(feature, layer) => {
layer.bindPopup(`
<b>${feature.properties.name}</b><br/>
Orders: ${feature.properties.orderCount}<br/>
Avg delivery: ${feature.properties.avgDeliveryMin} min
`);
}}
/>
</MapContainer>
);
}
Custom Icons and Controls
import L from "leaflet";
// Custom marker icon
const storeIcon = new L.Icon({
iconUrl: "/icons/store-pin.png",
iconSize: [32, 32],
iconAnchor: [16, 32],
popupAnchor: [0, -32],
});
// Custom map control (e.g., "Locate Me" button)
function LocateControl() {
const map = useMap();
return (
<button
className="leaflet-control"
onClick={() => map.locate({ setView: true, maxZoom: 16 })}
>
📍 My Location
</button>
);
}
Installation
npm install leaflet react-leaflet
npm install react-leaflet-cluster # Marker clustering
npm install @types/leaflet # TypeScript types
Examples
Example 1: User asks to set up leaflet
User: "Help me set up leaflet for my project"
The agent should:
- Check system requirements and prerequisites
- Install or configure leaflet
- Set up initial project structure
- Verify the setup works correctly
Example 2: User asks to build a feature with leaflet
User: "Create a dashboard using leaflet"
The agent should:
- Scaffold the component or configuration
- Connect to the appropriate data source
- Implement the requested feature
- Test and validate the output
Guidelines
- Free tiles — Use OpenStreetMap tiles (no API key, no cost); switch to Mapbox/Stadia for custom styling
- Marker clustering — Use
react-leaflet-clusterfor 100+ markers; prevents visual clutter and improves performance - GeoJSON for regions — Use GeoJSON layers for boundaries, zones, and polygons; style dynamically based on data
- Lazy load — Leaflet CSS and JS are ~40KB; lazy load the map component for better initial page load
- SSR compatibility — Leaflet requires
window; usedynamic(() => import("./Map"), { ssr: false })in Next.js - Tile caching — Use service workers to cache map tiles for offline support in PWAs
- Event handling — Use
useMapEventshook for click, zoom, move events; build interactive experiences - Lightweight alternative — At 42KB (gzipped), Leaflet is 5x smaller than Mapbox GL JS; choose Leaflet when you don't need 3D or custom styles