Map Arc Animated
terrae/arc-animatedFreeComponent
Animated curved arc between two points for flights, deliveries, and connections.
Install it
npx shadcn@latest add https://www.terrae.dev/arc-animated.jsonSource
1"use client"23import { useEffect, useRef, useState } 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, MapPath } from "./types"910type HeadType = "none" | "circle" | "square" | "arrow"1112type MapArcAnimatedProps = {13 id: string14 origin: MapCoordinates15 destination: MapCoordinates16 color?: string17 width?: number18 opacity?: number19 dashArray?: [number, number]20 height?: number21 segments?: number22 duration?: number23 autoStart?: boolean24 loop?: boolean25 loopDelay?: number26 headType?: HeadType27 headSize?: number28 showOriginMarker?: boolean29 originMarkerColor?: string30 showDestinationMarker?: boolean31 destinationMarkerColor?: string32 onComplete?: () => void33}3435const DEFAULT_COLOR = "#3b82f6"36const DEFAULT_WIDTH = 437const DEFAULT_OPACITY = 138const DEFAULT_HEIGHT = 0.339const DEFAULT_SEGMENTS = 5040const DEFAULT_DURATION = 200041const DEFAULT_AUTO_START = true42const DEFAULT_LOOP = false43const DEFAULT_LOOP_DELAY = 50044const DEFAULT_HEAD_TYPE: HeadType = "circle"45const DEFAULT_HEAD_SIZE = 1646const DEFAULT_SHOW_ORIGIN_MARKER = false47const DEFAULT_SHOW_DESTINATION_MARKER = false48const MARKER_RADIUS = 84950type HeadSvgProps = {51 type: HeadType52 size: number53 color: string54}5556const HeadSvg = ({ type, size, color }: HeadSvgProps) => {57 if (type === "none") {58 return null59 }6061 if (type === "arrow") {62 return (63 <svg width={size} height={size} viewBox="0 0 32 32" fill="none">64 <polygon points="28,16 8,4 8,28" fill={color} />65 </svg>66 )67 }6869 if (type === "square") {70 return (71 <svg width={size} height={size} viewBox="0 0 32 32" fill="none">72 <rect x="4" y="4" width="24" height="24" fill={color} />73 </svg>74 )75 }7677 return (78 <svg width={size} height={size} viewBox="0 0 32 32" fill="none">79 <circle cx="16" cy="16" r="12" fill={color} stroke="white" strokeWidth="3" />80 </svg>81 )82}8384const calculateBearing = (from: MapCoordinates, to: MapCoordinates): number => {85 const dLon = ((to[0] - from[0]) * Math.PI) / 18086 const lat1 = (from[1] * Math.PI) / 18087 const lat2 = (to[1] * Math.PI) / 1808889 const y = Math.sin(dLon) * Math.cos(lat2)90 const x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon)9192 return ((Math.atan2(y, x) * 180) / Math.PI + 360) % 36093}9495const generateArcPath = (96 origin: MapCoordinates,97// … 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 Blur Areablur-area | terrae | Components | Free | 1 dep | |
| Map Camera Followcamera-follow | terrae | Components | Free | 1 dep | |
| Map Choroplethchoropleth | terrae | Components | Free | 1 dep | |
| Map Circlecircle | terrae | Components | Free | 1 dep |
