mcpField
M
mapbox-style-patterns

mapbox-style-patterns

github.com/mapboxデザイン・UI6144 回インストール3 日前に更新
リポジトリ

mapbox-style-patterns について

一般的な地図用途に向けた Mapbox のスタイルパターンとレイヤー設定ガイドです。POI、不動産、データオーバーレイ、ナビゲーション、ダークテーマに加え、最適化とテストの例を扱います。

主な機能

  1. 01代表的な地図スタイルを5種類提示
  2. 02レイヤー設定例を紹介
  3. 03ズーム別の簡略化とデータ駆動スタイルを解説
  4. 04密集した POI 向けクラスタリングを提示
  5. 05ビジュアル回帰テスト項目を掲載

活用シーン

  1. 01飲食店や POI マップの設計
  2. 02物件と周辺施設の表示
  3. 03データオーバーレイ用ベースマップの構築
  4. 04ナビゲーションルートや夜間マップの設定

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mapbox/mcp-devkit-server --skill mapbox-style-patterns

インストール後、Claude Code で/mapbox-style-patternsを入力して読み込まれたか確認します。

詳細

Mapbox スタイルパターンのスキル

このスキルでは、一般的な地図のシナリオで使える、実績に裏打ちされたスタイルパターンとレイヤー構成を紹介します。

パターンライブラリ

パターン 1:レストラン/POI 検索

ユースケース: レストラン、カフェ、バーなどのポイント・オブ・インタレストを表示する一般ユーザー向けアプリ

視覚的な要件:

  • POI がすぐに目に入ること
  • ナビゲーション用の道路コンテキスト
  • 写真やコンテンツを重ねるためのニュートラルな背景
  • モバイル向けに最適化されていること

推奨レイヤー:

{
  "layers": [
    {
      "id": "background",
      "type": "background",
      "paint": {
        "background-color": "#f5f5f5"
      }
    },
    {
      "id": "water",
      "type": "fill",
      "source": "mapbox-streets",
      "source-layer": "water",
      "paint": {
        "fill-color": "#d4e4f7",
        "fill-opacity": 0.6
      }
    },
    {
      "id": "landuse-parks",
      "type": "fill",
      "source": "mapbox-streets",
      "source-layer": "landuse",
      "filter": ["==", "class", "park"],
      "paint": {
        "fill-color": "#e8f5e8",
        "fill-opacity": 0.5
      }
    },
    {
      "id": "roads-minor",
      "type": "line",
      "source": "mapbox-streets",
      "source-layer": "road",
      "filter": ["in", "class", "street", "street_limited"],
      "paint": {
        "line-color": "#e0e0e0",
        "line-width": {
          "base": 1.5,
          "stops": [
            [12, 0.5],
            [15, 2],
            [18, 6]
          ]
        }
      }
    },
    {
      "id": "roads-major",
      "type": "line",
      "source": "mapbox-streets",
      "source-layer": "road",
      "filter": ["in", "class", "primary", "secondary", "tertiary"],
      "paint": {
        "line-color": "#ffffff",
        "line-width": {
          "base": 1.5,
          "stops": [
            [10, 1],
            [15, 4],
            [18, 12]
          ]
        }
      }
    },
    {
      "id": "restaurant-markers",
      "type": "symbol",
      "source": "restaurants",
      "layout": {
        "icon-image": "restaurant-15",
        "icon-size": 1.5,
        "icon-allow-overlap": false,
        "text-field": ["get", "name"],
        "text-offset": [0, 1.5],
        "text-size": 12,
        "text-allow-overlap": false
      },
      "paint": {
        "icon-color": "#FF6B35",
        "text-color": "#333333",
        "text-halo-color": "#ffffff",
        "text-halo-width": 2
      }
    }
  ]
}

主な特徴:

  • 彩度を抑えたベースマップ(写真と競合しません)
  • コントラストの高いマーカー(#FF6B35 のオレンジが目立ちます)
  • 見やすい道路網(薄いグレーの背景に白)
  • 公園は表示しつつ控えめに
  • 読みやすさを高めるテキストハロー
パターン 2:不動産マップ

ユースケース: 物件検索、近隣エリアの探索、不動産物件の掲載

視覚的な要件:

  • 物件の境界が明確であること
  • 近隣エリアの情報が見えること
  • 施設(学校、公園、交通機関)が強調されていること
  • 価格や物件データを表示できること

推奨レイヤー:

{
  "layers": [
    {
      "id": "background",
      "type": "background",
      "paint": {
        "background-color": "#fafafa"
      }
    },
    {
      "id": "parks-green-spaces",
      "type": "fill",
      "source": "mapbox-streets",
      "source-layer": "landuse",
      "filter": ["in", "class", "park", "pitch", "playground"],
      "paint": {
        "fill-color": "#7cb342",
        "fill-opacity": 0.3
      }
    },
    {
      "id": "water",
      "type": "fill",
      "source": "mapbox-streets",
      "source-layer": "water",
      "paint": {
        "fill-color": "#42a5f5",
        "fill-opacity": 0.4
      }
    },
    {
      "id": "roads",
      "type": "line",
      "source": "mapbox-streets",
      "source-layer": "road",
      "paint": {
        "line-color": "#e0e0e0",
        "line-width": {
          "base": 1.2,
          "stops": [
            [10, 0.5],
            [15, 2],
            [18, 6]
          ]
        }
      }
    },
    {
      "id": "property-boundaries",
      "type": "line",
      "source": "properties",
      "paint": {
        "line-color": "#7e57c2",
        "line-width": 2,
        "line-opacity": 0.8
      }
    },
    {
      "id": "property-fills",
      "type": "fill",
      "source": "properties",
      "paint": {
        "fill-color": [
          "interpolate",
          ["linear"],
          ["get", "price"],
          200000,
          "#4caf50",
          500000,
          "#ffc107",
          1000000,
          "#f44336"
        ],
        "fill-opacity": 0.3
      }
    },
    {
      "id": "school-icons",
      "type": "symbol",
      "source": "composite",
      "source-layer": "poi_label",
      "filter": ["==", "class", "school"],
      "layout": {
        "icon-image": "school-15",
        "icon-size": 1.2
      },
      "paint": {
        "icon-opacity": 0.8
      }
    },
    {
      "id": "transit-stops",
      "type": "circle",
      "source": "transit",
      "paint": {
        "circle-radius": 6,
        "circle-color": "#2196f3",
        "circle-stroke-color": "#ffffff",
        "circle-stroke-width": 2
      }
    }
  ]
}

主な特徴:

  • 価格に応じて物件を色分け(緑→黄→赤)
  • 公園を目立つように表示(住宅購入者にとって重要です)
  • 学校と交通機関を明確に表示
  • 物件の境界を表示
  • すっきりとしたプロフェッショナルなデザイン
パターン 3:データ可視化用ベースマップ

ユースケース: コロプレスマップ、ヒートマップ、データオーバーレイ、分析ダッシュボード

視覚的な要件:

  • ベースマップを最小限にする(データを主役にします)
  • 邪魔にならない範囲でコンテキストを表示
  • さまざまな色のデータオーバーレイに対応
  • 暗いデータ表示では高コントラストも選択可能

推奨レイヤー:

{
  "layers": [
    {
      "id": "background",
      "type": "background",
      "paint": {
        "background-color": "#f0f0f0"
      }
    },
    {
      "id": "water",
      "type": "fill",
      "source": "mapbox-streets",
      "source-layer": "water",
      "paint": {
        "fill-color": "#d8d8d8",
        "fill-opacity": 0.5
      }
    },
    {
      "id": "admin-boundaries",
      "type": "line",
      "source": "mapbox-streets",
      "source-layer": "admin",
      "filter": ["in", "admin_level", 0, 1, 2],
      "paint": {
        "line-color": "#999999",
        "line-width": {
          "base": 1,
          "stops": [
            [0, 0.5],
            [10, 1],
            [15, 2]
          ]
        },
        "line-dasharray": [3, 2]
      }
    },
    {
      "id": "roads-major-simplified",
      "type": "line",
      "source": "mapbox-streets",
      "source-layer": "road",
      "filter": ["in", "class", "motorway", "primary"],
      "minzoom": 6,
      "paint": {
        "line-color": "#cccccc",
        "line-width": {
          "base": 1.2,
          "stops": [
            [6, 0.5],
            [10, 1],
            [15, 2]
          ]
        },
        "line-opacity": 0.5
      }
    },
    {
      "id": "place-labels-major",
      "type": "symbol",
      "source": "mapbox-streets",
      "source-layer": "place_label",
      "filter": ["in", "type", "city", "capital"],
      "layout": {
        "text-field": ["get", "name"],
        "text-size": {
          "base": 1,
          "stops": [
            [4, 10],
            [10, 14]
          ]
        },
        "text-font": ["Open Sans Semibold"]
      },
      "paint": {
        "text-color": "#666666",
        "text-halo-color": "#ffffff",
        "text-halo-width": 2
      }
    }
  ]
}

主な特徴:

  • グレースケールの配色(データの色を邪魔しません)
  • 詳細を最小限に(道路と境界のみ)
  • 方向を把握できるよう主要都市にラベルを表示
  • 全体的に不透明度を低く設定
  • データオーバーレイに最適
パターン 4:ナビゲーション/ルート案内マップ

ユースケース: ターンバイターン方式の道案内、ルート計画、配達アプリ

視覚的な要件:

  • ルートがはっきりと見えること
  • 現在地が常に明確であること
  • 曲がる地点が分かりやすいこと
  • 道路名が読みやすいこと
  • パフォーマンスが最適化されていること

推奨レイヤー:

{
  "layers": [
    {
      "id": "background",
      "type": "background",
      "paint": {
        "background-color": "#ffffff"
      }
    },
    {
      "id": "water",
      "type": "fill",
      "source": "mapbox-streets",
      "source-layer": "water",
      "paint": {
        "fill-color": "#a8d8ea"
      }
    },
    {
      "id": "landuse",
      "type": "fill",
      "source": "mapbox-streets",
      "source-layer": "landuse",
      "paint": {
        "fill-color": [
          "match",
          ["get", "class"],
          "park",
          "#d4edda",
          "hospital",
          "#f8d7da",
          "school",
          "#fff3cd",
          "#e9ecef"
        ],
        "fill-opacity": 0.5
      }
    },
    {
      "id": "roads-background",
      "type": "line",
      "source": "mapbox-streets",
      "source-layer": "road",
      "paint": {
        "line-color": "#333333",
        "line-width": {
          "base": 1.5,
          "stops": [
            [10, 2],
            [15, 8],
            [18, 20]
          ]
        },
        "line-opacity": 0.3
      }
    },
    {
      "id": "roads-foreground",
      "type": "line",
      "source": "mapbox-streets",
      "source-layer": "road",
      "paint": {
        "line-color": "#ffffff",
        "line-width": {
          "base": 1.5,
          "stops": [
            [10, 1],
            [15, 6],
            [18, 16]
          ]
        }
      }
    },
    {
      "id": "route-casing",
      "type": "line",
      "source": "route",
      "paint": {
        "line-color": "#0d47a1",
        "line-width": {
          "base": 1.5,
          "stops": [
            [10, 8],
            [15, 16],
            [18, 32]
          ]
        },
        "line-opacity": 0.4
      }
    },
    {
      "id": "route-line",
      "type": "line",
      "source": "route",
      "paint": {
        "line-color": "#2196f3",
        "line-width": {
          "base": 1.5,
          "stops": [
            [10, 6],
            [15, 12],
            [18, 24]
          ]
        }
      }
    },
    {
      "id": "user-location",
      "type": "circle",
      "source": "user-location",
      "paint": {
        "circle-radius": 8,
        "circle-color": "#2196f3",
        "circle-stroke-color": "#ffffff",
        "circle-stroke-width": 3
      }
    },
    {
      "id": "user-location-pulse",
      "type": "circle",
      "source": "user-location",
      "paint": {
        "circle-radius": {
          "base": 1,
          "stops": [
            [0, 16],
            [1, 24]
          ]
        },
        "circle-color": "#2196f3",
        "circle-opacity": {
          "base": 1,
          "stops": [
            [0, 0.4],
            [1, 0]
          ]
        }
      }
    },
    {
      "id": "turn-arrows",
      "type": "symbol",
      "source": "route-maneuvers",
      "layout": {
        "icon-image": ["get", "arrow-type"],
        "icon-size": 1.5,
        "icon-rotation-alignment": "map",
        "icon-rotate": ["get", "bearing"]
      }
    }
  ]
}

主な特徴:

  • 太く、コントラストの高いルート(白地に青)
  • 点滅するユーザー位置インジケーター
  • 曲がる地点に表示するターン矢印
  • 背景を簡素化(ルートに焦点を当てます)
  • コンテキスト用の土地利用の色分け
パターン 5:ダークモード/夜間テーマ

ユースケース: 目の疲れを軽減、夜間の使用、モダンなデザイン、バッテリー節約(OLED)

視覚的な要件:

  • 暗い背景
  • 輝度を抑える
  • コントラストを維持
  • テキストを読みやすくする
  • 快適に閲覧できること

推奨レイヤー:

{
  "layers": [
    {
      "id": "background",
      "type": "background",
      "paint": {
        "background-color": "#0a0a0a"
      }
    },
    {
      "id": "water",
      "type": "fill",
      "source": "mapbox-streets",
      "source-layer": "water",
      "paint": {
        "fill-color": "#1a237e",
        "fill-opacity": 0.5
      }
    },
    {
      "id": "parks",
      "type": "fill",
      "source": "mapbox-streets",
      "source-layer": "landuse",
      "filter": ["==", "class", "park"],
      "paint": {
        "fill-color": "#1b5e20",
        "fill-opacity": 0.4
      }
    },
    {
      "id": "buildings",
      "type": "fill",
      "source": "mapbox-streets",
      "source-layer": "building",
      "paint": {
        "fill-color": "#1a1a1a",
        "fill-opacity": 0.8,
        "fill-outline-color": "#2a2a2a"
      }
    },
    {
      "id": "roads-minor",
      "type": "line",
      "source": "mapbox-streets",
      "source-layer": "road",
      "filter": ["in", "class", "street", "street_limited"],
      "paint": {
        "line-color": "#2a2a2a",
        "line-width": {
          "base": 1.5,
          "stops": [
            [12, 0.5],
            [15, 2],
            [18, 6]
          ]
        }
      }
    },
    {
      "id": "roads-major",
      "type": "line",
      "source": "mapbox-streets",
      "source-layer": "road",
      "filter": ["in", "class", "primary", "secondary", "motorway"],
      "paint": {
        "line-color": "#3a3a3a",
        "line-width": {
          "base": 1.5,
          "stops": [
            [10, 1],
            [15, 4],
            [18, 12]
          ]
        }
      }
    },
    {
      "id": "labels",
      "type": "symbol",
      "source": "mapbox-streets",
      "source-layer": "place_label",
      "layout": {
        "text-field": ["get", "name"],
        "text-size": 12
      },
      "paint": {
        "text-color": "#e0e0e0",
        "text-halo-color": "#0a0a0a",
        "text-halo-width": 2
      }
    }
  ]
}

主な特徴:

  • 非常に暗い背景(#0a0a0a のほぼ黒)
  • 控えめな色の差(深い青や緑)
  • 暗いハローを付けた明るいテキスト(#e0e0e0)
  • 全体的に不透明度を低く設定
  • 暗い環境でも目に優しい

パターン選択ガイド

判断フロー

質問 1:主なコンテンツは何ですか?

  • ユーザーが追加したマーカー/ピン → POI 検索パターン
  • 物件データ/境界 → 不動産パターン
  • 統計/分析データ → データ可視化パターン
  • ルート/道案内 → ナビゲーションパターン

質問 2:どのような環境で閲覧しますか?

  • 日中/オフィス → ライトテーマ
  • 夜間/暗い環境 → ダークモードパターン
  • さまざまな環境 → テーマ切り替えを用意

質問 3:ユーザーの主な操作は何ですか?

  • 閲覧/探索 → POI を重視し、詳細を充実させる
  • ナビゲーション → 道路とルートの視認性を重視する
  • データ分析 → ベースマップを最小限にし、データを最大限に表示する
  • 場所の選択 → 境界を明確にし、コンテキストを表示する

質問 4:プラットフォームは何ですか?

  • モバイル → シンプルにし、タッチ領域を大きくして、詳細を減らす
  • デスクトップ → より多くの詳細や複雑な情報を含められます
  • 両方 → モバイルファーストで設計し、デスクトップ向けに拡張する

レイヤー最適化パターン

パフォーマンスパターン:ズームレベルに応じた簡略化
{
  "id": "roads",
  "type": "line",
  "source": "mapbox-streets",
  "source-layer": "road",
  "filter": [
    "step",
    ["zoom"],
    ["in", "class", "motorway", "trunk"],
    8,
    ["in", "class", "motorway", "trunk", "primary"],
    12,
    ["in", "class", "motorway", "trunk", "primary", "secondary"],
    14,
    true
  ],
  "paint": {
    "line-width": {
      "base": 1.5,
      "stops": [
        [4, 0.5],
        [10, 1],
        [15, 4],
        [18, 12]
      ]
    }
  }
}
エクスプレッションパターン:データ駆動型のスタイル設定
{
  "paint": {
    "circle-radius": [
      "interpolate",
      ["linear"],
      ["get", "population"],
      0,
      3,
      1000,
      5,
      10000,
      8,
      100000,
      12,
      1000000,
      20
    ],
    "circle-color": [
      "case",
      ["<", ["get", "temperature"], 0],
      "#2196f3",
      ["<", ["get", "temperature"], 20],
      "#4caf50",
      ["<", ["get", "temperature"], 30],
      "#ffc107",
      "#f44336"
    ]
  }
}
クラスタリングパターン:密集した POI に対応する
{
  "id": "clusters",
  "type": "circle",
  "source": "pois",
  "filter": ["has", "point_count"],
  "paint": {
    "circle-color": [
      "step",
      ["get", "point_count"],
      "#51bbd6", 10,
      "#f1f075", 30,
      "#f28cb1"
    ],
    "circle-radius": [
      "step",
      ["get", "point_count"],
      15, 10,
      20, 30,
      25
    ]
  }
},
{
  "id": "cluster-count",
  "type": "symbol",
  "source": "pois",
  "filter": ["has", "point_count"],
  "layout": {
    "text-field": ["get", "point_count_abbreviated"],
    "text-size": 12
  }
}

よくある変更

3D 建物を追加する
{
  "id": "3d-buildings",
  "type": "fill-extrusion",
  "source": "composite",
  "source-layer": "building",
  "minzoom": 15,
  "paint": {
    "fill-extrusion-color": "#aaa",
    "fill-extrusion-height": [
      "interpolate",
      ["linear"],
      ["zoom"],
      15,
      0,
      15.05,
      ["get", "height"]
    ],
    "fill-extrusion-base": [
      "interpolate",
      ["linear"],
      ["zoom"],
      15,
      0,
      15.05,
      ["get", "min_height"]
    ],
    "fill-extrusion-opacity": 0.6
  }
}
地形/陰影起伏図を追加する
{
  "sources": {
    "mapbox-dem": {
      "type": "raster-dem",
      "url": "mapbox://mapbox.mapbox-terrain-dem-v1"
    }
  },
  "layers": [
    {
      "id": "hillshade",
      "type": "hillshade",
      "source": "mapbox-dem",
      "paint": {
        "hillshade-exaggeration": 0.5,
        "hillshade-shadow-color": "#000000"
      }
    }
  ],
  "terrain": {
    "source": "mapbox-dem",
    "exaggeration": 1.5
  }
}
カスタムマーカーの追加
{
  "id": "custom-markers",
  "type": "symbol",
  "source": "markers",
  "layout": {
    "icon-image": "custom-marker",
    "icon-size": 0.8,
    "icon-anchor": "bottom",
    "icon-allow-overlap": true,
    "text-field": ["get", "name"],
    "text-offset": [0, -2],
    "text-anchor": "top",
    "text-size": 12
  },
  "paint": {
    "text-color": "#ffffff",
    "text-halo-color": "#000000",
    "text-halo-width": 2
  }
}

テストパターン

ビジュアルリグレッションのチェックリスト
  • ズームレベル4、8、12、16、20でテストします
  • モバイル(幅375px)で確認します
  • デスクトップ(幅1920px)で確認します
  • データが密な場合にテストします
  • データが疎な場合にテストします
  • ラベルの重なりを確認します
  • 色のコントラスト(WCAG)を確認します
  • 読み込みパフォーマンスをテストします

このスキルを使用するタイミング

次の場合にこのスキルを呼び出します。

  • 特定のユースケース向けに新しいマップスタイルを作成するとき
  • レイヤー設定の例を探しているとき
  • 一般的なマッピングパターンを実装するとき
  • 既存のスタイルを最適化するとき
  • 一般的なシナリオ向けの実証済みのレシピが必要なとき
  • スタイルの問題をデバッグするとき
  • Mapbox スタイルのベストプラクティスを学ぶとき

コメント