Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

mapbox

БесплатноБез исполняемых скриптовНе проверен

Mapbox is a platform for interactive web maps, geocoding and routing; Mapbox GL JS (v3) renders the maps in the browser. Use when a user asks to create…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Mapbox — Custom Interactive Maps

Overview

Mapbox provides custom interactive maps, geocoding, routing and geospatial data visualization. Mapbox GL JS renders vector maps in the browser (current major version 3, 3.33.0 at the time of writing); react-map-gl is the React wrapper (8.x); the REST APIs (Geocoding, Directions) are called with the same access token.

Instructions

Install and token

npm install mapbox-gl react-map-gl

Create a public access token (starts with pk.) at https://account.mapbox.com/ and keep it in an environment variable (NEXT_PUBLIC_MAPBOX_TOKEN). Restrict it to your site's URLs in the account page. Secret tokens (sk.) must never reach the browser. Without React: import mapboxgl from "mapbox-gl", set mapboxgl.accessToken, and new mapboxgl.Map({ container, style, center: [lng, lat], zoom }).

Basic Map

// react-map-gl v8: import from the /mapbox entry point (plain "react-map-gl" no longer works)
import Map, { Marker, Popup, NavigationControl, Source, Layer } from "react-map-gl/mapbox";
import "mapbox-gl/dist/mapbox-gl.css";
import { useState } from "react";

function StoreLocator() {
  const [selectedStore, setSelectedStore] = useState(null);

  return (
    <Map
      mapboxAccessToken={process.env.NEXT_PUBLIC_MAPBOX_TOKEN}
      initialViewState={{ longitude: -73.98, latitude: 40.75, zoom: 12 }}
      style={{ width: "100%", height: "100vh" }}
      mapStyle="mapbox://styles/mapbox/streets-v12"
    >
      <NavigationControl position="top-right" />

      {stores.map((store) => (
        <Marker
          key={store.id}
          longitude={store.lng}
          latitude={store.lat}
          onClick={() => setSelectedStore(store)}
        >
          <div className="store-pin">📍</div>
        </Marker>
      ))}

      {selectedStore && (
        <Popup
          longitude={selectedStore.lng}
          latitude={selectedStore.lat}
          onClose={() => setSelectedStore(null)}
        >
          <h3>{selectedStore.name}</h3>
          <p>{selectedStore.address}</p>
          <p>Open: {selectedStore.hours}</p>
        </Popup>
      )}
    </Map>
  );
}

Data Layers

// Heatmap layer for density visualization
function DeliveryHeatmap({ deliveries }) {
  const geojson = {
    type: "FeatureCollection",
    features: deliveries.map((d) => ({
      type: "Feature",
      geometry: { type: "Point", coordinates: [d.lng, d.lat] },
      properties: { weight: d.orderCount },
    })),
  };

  return (
    <Map mapboxAccessToken={process.env.NEXT_PUBLIC_MAPBOX_TOKEN} mapStyle="mapbox://styles/mapbox/streets-v12"
         initialViewState={{ longitude: -73.98, latitude: 40.75, zoom: 11 }}>
      <Source type="geojson" data={geojson}>
        <Layer
          id="deliveries-heat"
          type="heatmap"
          paint={{
            "heatmap-weight": ["get", "weight"],
            "heatmap-intensity": ["interpolate", ["linear"], ["zoom"], 0, 1, 15, 3],
            "heatmap-radius": ["interpolate", ["linear"], ["zoom"], 0, 5, 15, 30],
            "heatmap-color": [
              "interpolate", ["linear"], ["heatmap-density"],
              0, "rgba(0,0,255,0)", 0.2, "blue", 0.4, "cyan",
              0.6, "lime", 0.8, "yellow", 1, "red",
            ],
          }}
        />
      </Source>
    </Map>
  );
}

Geocoding and Directions

const TOKEN = process.env.NEXT_PUBLIC_MAPBOX_TOKEN;

// Geocoding API v6 — address to coordinates (v5 still answers but is the previous version)
const geocode = async (address: string) => {
  const res = await fetch(
    `https://api.mapbox.com/search/geocode/v6/forward?q=${encodeURIComponent(address)}&limit=1&access_token=${TOKEN}`
  );
  const data = await res.json();
  const feature = data.features[0];
  const [lng, lat] = feature.geometry.coordinates;
  return { lng, lat, place_name: feature.properties.full_address };
};

// Directions API — route between two points
const getRoute = async (start: [number, number], end: [number, number]) => {
  const res = await fetch(
    `https://api.mapbox.com/directions/v5/mapbox/driving/${start.join(",")};${end.join(",")}?geometries=geojson&access_token=${TOKEN}`
  );
  const data = await res.json();
  return {
    route: data.routes[0].geometry,       // GeoJSON LineString
    duration: data.routes[0].duration,     // seconds
    distance: data.routes[0].distance,     // meters
  };
};

Examples

Example 1: Store locator for a bakery chain

"Show our 12 bakeries on a map and open the address when someone clicks a pin."

Use the StoreLocator component above with stores loaded from your API ({ id, name, lng, lat, address, hours }). Put NEXT_PUBLIC_MAPBOX_TOKEN=pk... in .env.local. Result: a full-screen street map centered on Manhattan with 12 pins; clicking one opens a popup with name, address and opening hours. Import mapbox-gl/dist/mapbox-gl.css once or the popup and controls render unstyled.

Полный SKILL.md на GitHub

Установить mapbox в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл mapbox?

Mapbox is a platform for interactive web maps, geocoding and routing; Mapbox GL JS (v3) renders the maps in the browser. Use when a user asks to create interactive maps, add custom layers, implement geocoding, build navigation features, or visualize geospatial data with Mapbox.

Как установить скилл mapbox?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл mapbox запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить mapbox с