Compass
57.02% coveredInteractive compass with drag-to-rotate functionality.
Installation
First, make sure you have the base map component installed:
npx shadcn@latest add https://www.terrae.dev/map.jsonThen install the compass component:
npx shadcn@latest add https://www.terrae.dev/compass.jsonSizes
The compass supports t-shirt sizes (sm, md, lg, xl) or custom numeric pixel values. Each size is optimized for different use cases.
Minimal Mode
For a cleaner look, disable the outer ring and cardinal labels.
Bearing Display
Enable showBearing to display the current rotation angle in degrees below the compass.
Auto Rotate
Enable automatic rotation with the autoRotate prop. Control the speed with autoRotateSpeed (degrees per frame).
Properties
| Prop | Type | Description |
|---|---|---|
size | "sm" | "md" | "lg" | "xl" | number | Compass size. T-shirt sizes map to 48, 64, 80, 96 pixels respectively. |
position | "top-left" | "top-right" | "bottom-left" | "bottom-right" | Position of the compass on the map. |
showCardinals | boolean | Show N, S, E, W cardinal direction labels. |
showRing | boolean | Show outer ring with degree tick marks. |
showBearing | boolean | Display current bearing in degrees below the compass. |
autoRotate | boolean | Enable automatic rotation of the compass. |
autoRotateSpeed | number | Speed of auto rotation in degrees per frame. |
className | string | Additional CSS classes for the wrapper element. |