npx skills add ...
npx skills add mapbox/mapbox-agent-skills --skill mapbox-google-maps-migration
Migration guide for developers moving from Google Maps Platform to Mapbox GL JS, covering API equivalents, pattern translations, and key differences
npx skills add mapbox/mapbox-agent-skills --skill mapbox-google-maps-migration
Comprehensive guidance for migrating from Google Maps Platform to Mapbox GL JS. Provides API equivalents, pattern translations, and strategies for successful migration.
.setMap(map)Key Insight: Mapbox treats everything as data + styling, not individual objects.
Key Differences:
{lat, lng}, Mapbox uses [lng, lat]| Google Maps | Mapbox GL JS | Notes |
|---|---|---|
map.setCenter(latLng) | map.setCenter([lng, lat]) | Coordinate order reversed |
map.getCenter() | map.getCenter() | Returns LngLat object |
map.setZoom(zoom) | map.setZoom(zoom) | Same behavior |
map.getZoom() | map.getZoom() | Same behavior |
map.panTo(latLng) | map.panTo([lng, lat]) | Animated pan |
map.fitBounds(bounds) | map.fitBounds([[lng,lat],[lng,lat]]) | Different bound format |
map.setMapTypeId(type) | map.setStyle(styleUrl) | Completely different approach |
map.getBounds() | map.getBounds() | Similar |
| Google Maps | Mapbox GL JS | Notes |
|---|---|---|
google.maps.event.addListener(map, 'click', fn) | map.on('click', fn) | Simpler syntax |
event.latLng | event.lngLat | Event property name |
'center_changed' | 'move' / 'moveend' | Different event names |
'zoom_changed' | 'zoom' / 'zoomend' | Different event names |
'bounds_changed' | 'moveend' | No direct equivalent |
'mousemove' | 'mousemove' | Same |
'mouseout' | 'mouseleave' | Different name |
Google Maps:
Mapbox GL JS:
Google Maps:
Mapbox GL JS (Equivalent Approach):
Mapbox GL JS (Data-Driven Approach - Recommended for 100+ points):
Performance Advantage: Google Maps renders all markers as DOM elements (even when using the Data Layer), which becomes slow with 500+ markers. Mapbox's circle and symbol layers are rendered by WebGL, making them much faster for large datasets (1,000-10,000+ points). This is a significant advantage when building applications with many points.
Identify all Google Maps features you use:
Start with basic map initialization:
new google.maps.Map() with new mapboxgl.Map()Prioritize by complexity:
Change event syntax:
google.maps.event.addListener() -> map.on()latLng -> lngLat)Take advantage of Mapbox features:
Always double-check coordinate order!
Never remove and re-add layers to update data — this reinitializes WebGL resources and causes a visible flash. Instead:
Consider staying with Google Maps if:
Remember: lng, lat order in Mapbox!
Works with:
The following reference files contain detailed migration guides for specific topics. Load them when working on those areas:
references/shapes-geocoding.md — Polygons, Polylines, Custom Icons, Geocodingreferences/directions-controls.md — Directions/Routing, Controlsreferences/clustering-styling.md — Clustering, Styling/Appearancereferences/data-performance.md — Data Updates, Performance, Common Migration Patterns (Store Locator, Drawing Tools, Heatmaps)references/api-services.md — API Services Comparison, Pricing, Plugins, Framework Integration, Testing, Migration ChecklistTo load a reference, read the file relative to this skill directory, e.g.: