Skip to main content

Maps

Maps are the most expensive feature nobody budgets for. Tile requests, geocoding calls, and marker rendering add up fast.

Pick the map library before you pick the map provider. The library locks you in harder than the tile source.

Library Selection

CriteriaMapBox GL JSLeafletGoogle Mapsreact-map-gl
CostFree to 50K loads/moFree (OSS)$200 credit then payUses MapBox
Bundle size~200 KB~40 KBExternal script~60 KB + MapBox
Vector tilesYesPlugin onlyYesYes
3D terrainYesNoLimitedYes
OfflineYes (paid)Yes (manual)NoVia MapBox
React wrapperreact-map-glreact-leaflet@react-google-mapsNative
Best forRich interactivityLightweight, budgetEnterprise, Places APIReact + MapBox

Decision Rule

SituationChoiceWhy
Budget is zeroLeaflet + OpenStreetMapNo API keys, no bills
Need geocoding/placesGoogle MapsPlaces API is unmatched
Need custom stylingMapBoxVector tiles, full control
Need 3D or terrainMapBoxOnly real option in React
Simple location pinsLeafletLightest bundle, fastest render

Key Patterns

PatternWhatWhy
Lazy load mapImport map component dynamicallyMaps are heavy; defer until visible
Cluster markersGroup nearby pointsPerformance past 100 markers
Viewport cullingOnly render visible markersMemory management
Server-side staticGenerate static map image on serverZero JS for non-interactive maps

Context

Questions

When does a static map image replace an interactive map?

  • What is the real cost per user of MapBox vs Google Maps at 10K monthly active users?
  • How do you test map components without hitting external tile servers?
  • When does marker count force a switch from DOM to canvas rendering?