All skills
mapbox avatar

/mapbox-maplibre-migration

@9077a82 official
by mapboxmapbox/mapbox-agent-skills80 stars
17

Guide for migrating from MapLibre GL JS to Mapbox GL JS, covering API compatibility, token setup, style configuration, and the benefits of Mapbox's official support and ecosystem

Use this Skill: https://skilld.dev/gh/mapbox/mapbox-agent-skills/mapbox-maplibre-migration

This session only. Nothing lands on disk.

referencesexclusive-features.md

≈794 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Mapbox-Exclusive Features

After migration, you gain access to these Mapbox-only features:

Premium Vector Tiles

  • Streets: Comprehensive road network with names, shields, and routing data
  • Satellite: High-resolution global imagery updated regularly
  • Terrain: Elevation data with hillshading and 3D terrain
  • Traffic: Real-time traffic data (with Navigation SDK)

Mapbox APIs

Use these APIs alongside your map for enhanced functionality:

// Geocoding API - Convert addresses to coordinates
const response = await fetch(
  `https://api.mapbox.com/search/geocode/v6/forward?q=San+Francisco&access_token=${mapboxgl.accessToken}`
);

// Directions API - Get turn-by-turn directions
const directions = await fetch(
  `https://api.mapbox.com/directions/v5/mapbox/driving/-122.42,37.78;-122.45,37.76?access_token=${mapboxgl.accessToken}`
);

// Isochrone API - Calculate travel time polygons
const isochrone = await fetch(
  `https://api.mapbox.com/isochrone/v1/mapbox/driving/-122.42,37.78?contours_minutes=5,10,15&access_token=${mapboxgl.accessToken}`
);

Mapbox Studio

  • Visual style editor with live preview
  • Dataset management and editing
  • Tilesets with custom data upload
  • Collaborative team features
  • Style versioning and publishing

Advanced Features (v2.9+)

  • Globe projection: Seamless transition from globe to Mercator
  • 3D buildings: Extrusion with real building footprints
  • Custom terrain: Use your own DEM sources
  • Sky layer: Realistic atmospheric rendering

Framework Integration

Migration works identically across all frameworks. See mapbox-web-integration-patterns skill for detailed React, Vue, Svelte, Angular patterns.

React Example

import { useRef, useEffect } from 'react';
import mapboxgl from 'mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';

// Set token once (can be in app initialization)
mapboxgl.accessToken = process.env.REACT_APP_MAPBOX_TOKEN;

function MapComponent() {
  const mapRef = useRef(null);
  const mapContainerRef = useRef(null);

  useEffect(() => {
    mapRef.current = new mapboxgl.Map({
      container: mapContainerRef.current,
      style: 'mapbox://styles/mapbox/streets-v12',
      center: [-122.4194, 37.7749],
      zoom: 12
    });

    return () => {
      mapRef.current.remove();
    };
  }, []);

  return <div ref={mapContainerRef} style={{ height: '100vh' }} />;
}

Just replace maplibregl with mapboxgl and update token/style - everything else is identical!

Vue Example

<template>
  <div ref="mapContainer" class="map-container"></div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import mapboxgl from 'mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';

mapboxgl.accessToken = import.meta.env.VITE_MAPBOX_TOKEN;

const mapContainer = ref(null);
let map = null;

onMounted(() => {
  map = new mapboxgl.Map({
    container: mapContainer.value,
    style: 'mapbox://styles/mapbox/streets-v12',
    center: [-122.4194, 37.7749],
    zoom: 12
  });
});

onUnmounted(() => {
  map?.remove();
});
</script>

<style scoped>
.map-container {
  height: 100vh;
}
</style>

Source: SKILL.md on GitHub

No alerts14d5 checks · Risk SAFE
  • Gen Agent Trust Hub14d

    The skill is a legitimate technical guide for migrating from MapLibre GL JS to Mapbox GL JS. It follows industry best practices, provides clear security guidance regarding API token management, and utilizes official Mapbox resources.

  • Socket14d

    No alerts

  • Snyk14d

    Risk: LOW · No issues

  • Runlayer6mo

    2/2 files flagged

  • ZeroLeaks5mo

    1 finding · Score: 82/100

Signed by skilld at 9077a82. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 8 hours ago.

Activeupdated 2 weeks ago
  • mapbox
  • maplibre
  • migration
  • gl-js
  • mapping
  • cartography
  • vector-tiles
  • web-mapping

README badge

README badge for mapbox/mapbox-agent-skills/mapbox-maplibre-migration

Guides migration from MapLibre GL JS to Mapbox GL JS, detailing the ~95% API compatibility, token setup, style configuration, and the transition path for plugins and dependencies. Covers account creation, package updates, environment variable management, and common migration pitfalls like token security and CDN URLs.

Generated from the current SKILL.md.

Does the API stay the same when migrating from MapLibre to Mapbox?
Yes, the APIs are approximately 95% identical because MapLibre forked from Mapbox GL JS v1.13.0. All map methods, events, layers, sources, markers, and controls work exactly the same — only imports, the token setup, and style URLs need to change.
What do I need to change in my code to migrate?
You must change the package name (maplibre-gl to mapbox-gl), update imports, set mapboxgl.accessToken before map initialization, switch style URLs to mapbox:// format, and replace any @maplibre/* plugins with their Mapbox equivalents. Everything else stays the same.
Do I need to pay to use Mapbox GL JS?
Mapbox offers a generous free tier with 50,000 map loads per month. You only pay for usage beyond that, making it suitable for many applications without cost.
How do I securely manage my Mapbox access token?
Store your token in a .env file and set it before map initialization using an environment variable (e.g., process.env.VITE_MAPBOX_TOKEN). Add .env to .gitignore to prevent committing tokens to git, and configure URL restrictions in the Mapbox dashboard for additional security.
What happens to my custom styles and layers when migrating?
Your custom styling, GeoJSON handling, layer definitions, and expressions work identically in both libraries. You can continue using custom styles from Mapbox Studio or switch to Mapbox's built-in professionally maintained styles.

Generated from the current SKILL.md. These answers refresh after source changes.