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.

referencesclustering-styling.md

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

Clustering and Styling

Clustering

Google Maps

// Requires MarkerClusterer library
import MarkerClusterer from '@googlemaps/markerclustererplus';

const markers = locations.map((loc) => new google.maps.Marker({ position: loc, map: map }));

new MarkerClusterer(map, markers, {
  imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'
});

Mapbox GL JS

// Built-in clustering support
map.addSource('points', {
  type: 'geojson',
  data: geojsonData,
  cluster: true,
  clusterMaxZoom: 14,
  clusterRadius: 50
});

// Cluster circles
map.addLayer({
  id: 'clusters',
  type: 'circle',
  source: 'points',
  filter: ['has', 'point_count'],
  paint: {
    'circle-color': ['step', ['get', 'point_count'], '#51bbd6', 100, '#f1f075', 750, '#f28cb1'],
    'circle-radius': ['step', ['get', 'point_count'], 20, 100, 30, 750, 40]
  }
});

// Cluster count labels
map.addLayer({
  id: 'cluster-count',
  type: 'symbol',
  source: 'points',
  filter: ['has', 'point_count'],
  layout: {
    'text-field': '{point_count_abbreviated}',
    'text-size': 12
  }
});

// Unclustered points
map.addLayer({
  id: 'unclustered-point',
  type: 'circle',
  source: 'points',
  filter: ['!', ['has', 'point_count']],
  paint: {
    'circle-color': '#11b4da',
    'circle-radius': 8
  }
});

Key Advantage: Mapbox clustering is built-in and highly performant.

Styling and Appearance

Map Types vs. Styles

Google Maps:

  • Limited map types: roadmap, satellite, hybrid, terrain
  • Styling via styles array (complex)

Mapbox GL JS:

  • Full control over every visual element
  • Pre-built styles: standard, standard-satellite, streets, outdoors, light, dark
  • Custom styles via Mapbox Studio for unique branding and design
  • Dynamic styling based on data properties
  • For classic styles (pre Mapbox Standard) you can modify style programmatically by using the setPaintProperty()

Custom Styling Example

Google Maps:

const styledMapType = new google.maps.StyledMapType(
  [
    { elementType: 'geometry', stylers: [{ color: '#242f3e' }] },
    { elementType: 'labels.text.stroke', stylers: [{ color: '#242f3e' }] }
    // ... many more rules
  ],
  { name: 'Dark' }
);

map.mapTypes.set('dark', styledMapType);
map.setMapTypeId('dark');

Mapbox GL JS:

// Use pre-built style
map.setStyle('mapbox://styles/mapbox/dark-v11');

// Or create custom style in Mapbox Studio and reference it
map.setStyle('mapbox://styles/yourusername/your-style-id');

// Modify classic styles programmatically
map.setPaintProperty('water', 'fill-color', '#242f3e');

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.