Map Compare
terrae/compareFreeComponent
Side-by-side map comparison component.
Install it
npx shadcn@latest add https://www.terrae.dev/compare.jsonSource
1"use client"23import type { ReactNode } from "react"4import { Map } from "./map"5import { cn } from "@/lib/utils"6import type { MapProjection, MapCoordinates, MapCompareOrientation } from "./types"78const DEFAULT_CENTER: MapCoordinates = [0, 0]9const DEFAULT_ZOOM = 210const DEFAULT_BEARING = 011const DEFAULT_PITCH = 012const DEFAULT_SIZE = 5013const DEFAULT_ORIENTATION: MapCompareOrientation = "horizontal"1415const LABEL_BASE_STYLES = "absolute z-10 bg-background/95 backdrop-blur-sm border rounded px-2 py-1 text-xs font-medium"1617type MapCompareProps = {18 accessToken?: string19 loader?: ReactNode20 beforeStyle?: string21 afterStyle?: string22 center?: MapCoordinates23 zoom?: number24 bearing?: number25 pitch?: number26 projection?: MapProjection27 defaultSize?: number28 orientation?: MapCompareOrientation29 showLabels?: boolean30}3132export const MapCompare = ({33 accessToken,34 loader,35 beforeStyle,36 afterStyle,37 center = DEFAULT_CENTER,38 zoom = DEFAULT_ZOOM,39 bearing = DEFAULT_BEARING,40 pitch = DEFAULT_PITCH,41 projection,42 defaultSize = DEFAULT_SIZE,43 orientation = DEFAULT_ORIENTATION,44 showLabels = false,45}: MapCompareProps) => {46 const isVertical = orientation === "vertical"4748 const beforeLabel = isVertical ? "Top" : "Before"49 const afterLabel = isVertical ? "Bottom" : "After"5051 const beforeLabelPosition = "top-3 left-3"52 const afterLabelPosition = isVertical ? "bottom-3 right-3" : "top-3 right-3"5354 return (55 <div className={cn("relative w-full h-full", isVertical ? "flex flex-col" : "flex")}>56 <MapPanel57 accessToken={accessToken}58 center={center}59 zoom={zoom}60 bearing={bearing}61 pitch={pitch}62 projection={projection}63 style={beforeStyle}64 loader={loader}65 label={beforeLabel}66 labelPosition={beforeLabelPosition}67 isVertical={isVertical}68 size={defaultSize}69 showLabel={showLabels}70 />71 <MapPanel72 accessToken={accessToken}73 center={center}74 zoom={zoom}75 bearing={bearing}76 pitch={pitch}77 projection={projection}78 style={afterStyle}79 loader={loader}80 label={afterLabel}81 labelPosition={afterLabelPosition}82 isVertical={isVertical}83 size={100 - defaultSize}84 showLabel={showLabels}85 />86 </div>87 )88}8990type MapPanelProps = {91 accessToken?: string92 center: MapCoordinates93 zoom: number94 bearing: number95 pitch: number96 isVertical: boolean97// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from terrae
All 40 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Map Animated Circleanimated-circle | terrae | Components | Free | 1 dep | |
| Map Animated Footprintanimated-footprint | terrae | Components | Free | 2 deps | |
| Map Animated Polygonanimated-polygon | terrae | Components | Free | 1 dep | |
| Map Animated Pulseanimated-pulse | terrae | Components | Free | 1 dep | |
| Map Arc Animatedarc-animated | terrae | Components | Free | 1 dep | |
| Map Blur Areablur-area | terrae | Components | Free | 1 dep | |
| Map Camera Followcamera-follow | terrae | Components | Free | 1 dep | |
| Map Choroplethchoropleth | terrae | Components | Free | 1 dep |
