All skills
mapbox avatar

/mapbox-google-maps-migration

@65bab68 official
by mapboxmapbox/mapbox-agent-skills80 stars
17

Migration guide for developers moving from Google Maps Platform to Mapbox GL JS, covering API equivalents, pattern translations, and key differences

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

This session only. Nothing lands on disk.

referencesdirections-controls.md

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

Directions, Routing, and Controls

Directions / Routing

Google Maps

const directionsService = new google.maps.DirectionsService();
const directionsRenderer = new google.maps.DirectionsRenderer();
directionsRenderer.setMap(map);

directionsService.route(
  {
    origin: 'San Francisco, CA',
    destination: 'Los Angeles, CA',
    travelMode: 'DRIVING'
  },
  (response, status) => {
    if (status === 'OK') {
      directionsRenderer.setDirections(response);
    }
  }
);

Mapbox GL JS

// Use Mapbox Directions API
const origin = [-122.4194, 37.7749];
const destination = [-118.2437, 34.0522];

fetch(
  `https://api.mapbox.com/directions/v5/mapbox/driving/${origin.join(',')};${destination.join(',')}?geometries=geojson&access_token=${mapboxgl.accessToken}`
)
  .then((response) => response.json())
  .then((data) => {
    const route = data.routes[0].geometry;

    map.addSource('route', {
      type: 'geojson',
      data: {
        type: 'Feature',
        geometry: route
      }
    });

    map.addLayer({
      id: 'route',
      type: 'line',
      source: 'route',
      paint: {
        'line-color': '#3887be',
        'line-width': 5
      }
    });
  });

// Or use @mapbox/mapbox-gl-directions plugin
const directions = new MapboxDirections({
  accessToken: mapboxgl.accessToken
});

map.addControl(directions, 'top-left');

Controls

Google Maps

// Controls are automatic, can configure:
map.setOptions({
  zoomControl: true,
  mapTypeControl: true,
  streetViewControl: false,
  fullscreenControl: true
});

Mapbox GL JS

// Add controls explicitly
map.addControl(new mapboxgl.NavigationControl()); // Zoom + rotation
map.addControl(new mapboxgl.FullscreenControl());
map.addControl(new mapboxgl.GeolocateControl());
map.addControl(new mapboxgl.ScaleControl());

// Position controls
map.addControl(new mapboxgl.NavigationControl(), 'top-right');

Source: SKILL.md on GitHub

1 warning15d5 checks · Risk SAFE
  • Gen Agent Trust Hub15d

    This skill is a safe and educational migration guide for developers moving from Google Maps to Mapbox GL JS. It provides technical comparisons, API equivalents, and best practices for performance optimization. All external references and code samples target official Mapbox services and reputable open-source libraries.

  • Socket15d

    No alerts

  • Snyk15d

    Risk: LOW · No issues

  • Runlayer7mo

    2/2 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

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

Last checked against GitHub 5 hours ago.

Activeupdated 6 months ago
  • mapbox
  • google-maps
  • migration
  • mapping
  • javascript
  • geospatial
  • gl-js
  • web-mapping

README badge

README badge for mapbox/mapbox-agent-skills/mapbox-google-maps-migration

Guides developers migrating from Google Maps Platform to Mapbox GL JS, covering API method equivalents, coordinate order differences, and architectural patterns. Includes reference tables for map methods and events, marker strategies for different data volumes, and gotchas like timing issues and data updates that cause visual flashing.

Generated from the current SKILL.md.

Does Mapbox have a Street View equivalent?
No. Street View is not available in Mapbox GL JS, so if Street View is critical to your application, you should stay with Google Maps.
What's the coordinate order difference between Google Maps and Mapbox?
Google Maps uses {lat, lng} while Mapbox uses [lng, lat] (reversed). This applies to all methods: map.setCenter(), marker.setLngLat(), fitBounds(), etc.
How do I handle large numbers of markers in Mapbox?
For 100+ points, use data-driven layers (GeoJSON sources + circle/symbol layers) instead of individual marker objects. Mapbox renders these with WebGL, making them much faster than DOM-based markers for 1,000-10,000+ points.
How do I update marker data without causing a visual flash?
Call map.getSource('source-id').setData(newGeoJSON) to update data in place, or use map.setFilter() to filter existing data on the GPU. Never remove and re-add layers to update data, as this reinitializes WebGL resources and causes a visible flash.
What authentication method does Mapbox use?
Mapbox uses access tokens set in code (mapboxgl.accessToken = 'YOUR_TOKEN'), whereas Google Maps uses API keys in the script tag.

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