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.

referencesapi-compatibility.md

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

API Compatibility Matrix

100% Compatible APIs

These work identically in both libraries:

// Map methods
map.setCenter([lng, lat]);
map.setZoom(zoom);
map.fitBounds(bounds);
map.panTo([lng, lat]);
map.flyTo({ center, zoom });
map.getCenter();
map.getZoom();
map.getBounds();
map.resize();

// Events
map.on('load', callback);
map.on('click', callback);
map.on('move', callback);
map.on('zoom', callback);
map.on('rotate', callback);

// Markers
new mapboxgl.Marker();
marker.setLngLat([lng, lat]);
marker.setPopup(popup);
marker.addTo(map);
marker.remove();
marker.setDraggable(true);

// Popups
new mapboxgl.Popup();
popup.setLngLat([lng, lat]);
popup.setHTML(html);
popup.setText(text);
popup.addTo(map);

// Sources & Layers
map.addSource(id, source);
map.removeSource(id);
map.addLayer(layer);
map.removeLayer(id);
map.getSource(id);
map.getLayer(id);

// Styling
map.setPaintProperty(layerId, property, value);
map.setLayoutProperty(layerId, property, value);
map.setFilter(layerId, filter);

// Controls
map.addControl(control, position);
new mapboxgl.NavigationControl();
new mapboxgl.GeolocateControl();
new mapboxgl.FullscreenControl();
new mapboxgl.ScaleControl();

Side-by-Side Example

MapLibre GL JS (Before)

import maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';

// No token needed for OSM tiles

const map = new maplibregl.Map({
  container: 'map',
  style: 'https://demotiles.maplibre.org/style.json',
  center: [-122.4194, 37.7749],
  zoom: 12
});

map.on('load', () => {
  new maplibregl.Marker()
    .setLngLat([-122.4194, 37.7749])
    .setPopup(new maplibregl.Popup().setText('San Francisco'))
    .addTo(map);
});

Mapbox GL JS (After)

import mapboxgl from 'mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';

// Add your Mapbox token
mapboxgl.accessToken = 'pk.your_mapbox_access_token';

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

map.on('load', () => {
  new mapboxgl.Marker()
    .setLngLat([-122.4194, 37.7749])
    .setPopup(new mapboxgl.Popup().setText('San Francisco'))
    .addTo(map);
});

What's different: Package, import, token, and style URL. Everything else is identical.

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 6 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.