Map Line Radial
terrae/line-radialFreeComponent
Radial lines from a center point to multiple destinations with optional markers.
Install it
npx shadcn@latest add https://www.terrae.dev/line-radial.jsonSource
1"use client"23import { useEffect, useRef, useState, type ReactNode } from "react"4import { createPortal } from "react-dom"5import type mapboxgl from "mapbox-gl"6import { mapgl } from "./map-library"7import { useMap } from "./hooks"8import type { MapCoordinates } from "./types"910type LineCurvature = number | "auto"1112type RadialDestination =13 | MapCoordinates14 | {15 coordinates: MapCoordinates16 color?: string17 label?: string18 }1920type MapLineRadialProps = {21 id: string22 origin: MapCoordinates23 destinations: RadialDestination[]24 color?: string25 width?: number26 opacity?: number27 dashArray?: [number, number]28 curvature?: LineCurvature29 curveSegments?: number30 duration?: number31 staggerDelay?: number32 autoStart?: boolean33 loop?: boolean34 loopDelay?: number35 showOriginMarker?: boolean36 originMarkerColor?: string37 originMarkerIcon?: ReactNode38 originMarkerPulse?: boolean39 showDestinationMarkers?: boolean40 destinationMarkerColor?: string41 destinationMarkerIcon?: ReactNode42 showTravelingMarker?: boolean43 travelingMarkerColor?: string44 travelingMarkerIcon?: ReactNode45 onLineComplete?: (index: number, destination: MapCoordinates) => void46 onComplete?: () => void47}4849const DEFAULT_COLOR = "#3b82f6"50const DEFAULT_WIDTH = 251const DEFAULT_OPACITY = 0.852const DEFAULT_CURVATURE = 0.353const DEFAULT_CURVE_SEGMENTS = 5054const DEFAULT_DURATION = 200055const DEFAULT_STAGGER_DELAY = 20056const DEFAULT_AUTO_START = true57const DEFAULT_LOOP = false58const DEFAULT_LOOP_DELAY = 100059const DEFAULT_SHOW_ORIGIN_MARKER = true60const DEFAULT_ORIGIN_MARKER_COLOR = "#ef4444"61const DEFAULT_ORIGIN_MARKER_PULSE = true62const DEFAULT_SHOW_DESTINATION_MARKERS = true63const DEFAULT_SHOW_TRAVELING_MARKER = false6465const ORIGIN_MARKER_SIZE = 3266const ORIGIN_MARKER_RADIUS = 1067const DESTINATION_MARKER_SIZE = 2468const DESTINATION_MARKER_RADIUS = 669const PULSE_RADIUS = 2070const TRAVELING_MARKER_RADIUS = 67172const getDestinationCoordinates = (destination: RadialDestination): MapCoordinates => {73 if (Array.isArray(destination)) {74 return destination75 }76 return destination.coordinates77}7879const getDestinationColor = (destination: RadialDestination): string | undefined => {80 if (Array.isArray(destination)) {81 return undefined82 }83 return destination.color84}8586const calculateCurvature = (87 origin: MapCoordinates,88 destination: MapCoordinates,89 baseCurvature: LineCurvature90): number => {91 if (baseCurvature !== "auto") {92 return baseCurvature93 }9495// … 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 |
