This library is not production-ready yet. Developers should use it with caution and expect breaking changes.

Sync

Synchronized multi-map component where panning, zooming, or rotating one map updates all others in real-time.

Installation

First, make sure you have the base map component installed:

npx shadcn@latest add https://www.terrae.dev/map.json

Then install the sync component:

npx shadcn@latest add https://www.terrae.dev/sync.json
Light
Dark

Vertical Layout

Use layout="vertical" to stack maps vertically. This works well for narrow containers or when comparing maps that benefit from a top-bottom view.

Streets
Satellite

Four-Map Grid

Pass four maps with layout="grid" to create a 2x2 grid. This allows comparing multiple styles simultaneously - street, satellite, light, and dark themes all synced together.

Light
Dark
Streets
Satellite

Satellite Comparison

Compare satellite imagery with labeled satellite views to understand how street overlays enhance navigation.

Satellite
Satellite + Streets

Navigation Styles

Compare day and night navigation styles to see how maps adapt for different driving conditions.

Day Navigation
Night Navigation

Terrain Comparison

Use pitch to tilt the maps and compare how different styles render mountainous terrain. The grid layout with four maps makes it easy to compare multiple perspectives at once.

Outdoors
Satellite
Streets
Light

Properties

PropertyTypeDefaultDescription
accessTokenstringrequiredMapbox access token
mapsMapConfig[]requiredArray of 2 or 4 map configurations
layout"horizontal" | "vertical" | "grid""horizontal"Layout arrangement for the maps
showLabelsbooleanfalseShow labels on each map panel
center[number, number][0, 0]Initial map center as [longitude, latitude]
zoomnumber2Initial zoom level
pitchnumber0Map tilt angle (0-85 degrees)
bearingnumber0Map rotation (-360 to 360 degrees)
projectionstring"mercator"Map projection type
loaderReactNodeGlobe spinnerCustom loading indicator

Map Configuration

Each map in the maps array accepts these properties:

PropertyTypeDescription
stylestringMapbox style URL (overrides theme)
styles{ light?: string, dark?: string }Theme-aware style URLs
labelstringCustom label for the map panel

Notes

  • Each map is a separate Mapbox instance, which means billing applies per map
  • Synchronization is bidirectional - interact with any map to update all others
  • The grid layout requires exactly 4 maps; 2 maps work with horizontal or vertical layouts
  • Movement sync uses Mapbox's move event for smooth, real-time updates
  • Custom labels can be set per map, or use the default position-based labels

Comparison vs Sync

MapCompare shows two maps side-by-side without synchronization - each map can be panned independently. MapSync keeps all maps synchronized - moving one moves all. Use MapCompare when you want independent exploration, use MapSync when you want to compare the same location across different styles.