⚠️ Early Stage Project: This library is not production-ready yet. Developers should use it with caution and expect breaking changes.

Compare

Compare two map views side-by-side or stacked with customizable orientation.

Installation

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

npx shadcn@latest add https://terrae.vercel.app/maps/map.json

Then install the compare component:

npx shadcn@latest add https://terrae.vercel.app/maps/map-compare.json
Before
After

Custom Map Styles

Use the beforeStyle and afterStyle props to compare any two Mapbox styles. This is useful for comparing different visualization approaches, showing before/after changes, or demonstrating map updates.

Before
After

Vertical OrientationNew

Use the orientation prop to switch between horizontal (side-by-side) and vertical (stacked) layouts. Vertical orientation is useful for comparing maps on narrow screens or when you want to emphasize vertical changes in the map data.

Top
Bottom

Properties

PropertyTypeDefaultDescription
accessTokenstringrequiredMapbox access token
orientationNew"horizontal" | "vertical""horizontal"Layout orientation for the comparison
showLabelsNewbooleanfalseShow labels on each map panel
beforeStylestringlight themeStyle URL for the before/top map
afterStylestringdark themeStyle URL for the after/bottom map
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
defaultSizenumber50Initial split position (0-100 percentage)

Notes

  • Renders two independent map instances, which doubles map load billing
  • Each map can be interacted with independently - zoom and pan are not synchronized
  • Set defaultSize to control the initial split position (0-100)
  • Labels are hidden by default - use showLabels to display them
  • Vertical orientation uses "Top" and "Bottom" labels instead of "Before" and "After"