Map Line Animated
terrae/line-animatedFreeComponent
Animated path and route animations on the map.
Install it
npx shadcn@latest add https://www.terrae.dev/line-animated.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 { MapPath } from "./types"910type MapLineAnimatedProps = {11 id: string12 path: MapPath13 color?: string14 width?: number15 opacity?: number16 dashArray?: [number, number]17 duration?: number18 showMarker?: boolean19 markerColor?: string20 markerIcon?: ReactNode21 markerBorderless?: boolean22 autoStart?: boolean23 loop?: boolean24 onComplete?: () => void25}2627const DEFAULT_COLOR = "#3b82f6"28const DEFAULT_WIDTH = 429const DEFAULT_OPACITY = 130const DEFAULT_DURATION = 300031const DEFAULT_SHOW_MARKER = true32const DEFAULT_MARKER_COLOR = "#3b82f6"33const DEFAULT_MARKER_BORDERLESS = false34const DEFAULT_AUTO_START = true35const DEFAULT_LOOP = false36const LOOP_RESTART_DELAY_MS = 5003738export const MapLineAnimated = ({39 id,40 path,41 color = DEFAULT_COLOR,42 width = DEFAULT_WIDTH,43 opacity = DEFAULT_OPACITY,44 dashArray,45 duration = DEFAULT_DURATION,46 showMarker = DEFAULT_SHOW_MARKER,47 markerColor = DEFAULT_MARKER_COLOR,48 markerIcon,49 markerBorderless = DEFAULT_MARKER_BORDERLESS,50 autoStart = DEFAULT_AUTO_START,51 loop = DEFAULT_LOOP,52 onComplete,53}: MapLineAnimatedProps) => {54 const { map, isLoaded } = useMap()5556 const initializedRef = useRef(false)57 const styleLoadedRef = useRef(false)58 const animationFrameRef = useRef<number | undefined>(undefined)59 const htmlMarkerRef = useRef<mapboxgl.Marker | null>(null)60 const markerElementRef = useRef<HTMLDivElement | null>(null)61 const startTimeRef = useRef<number>(0)62 const durationRef = useRef(duration)63 const pathRef = useRef(path)64 const colorRef = useRef(color)65 const widthRef = useRef(width)66 const opacityRef = useRef(opacity)67 const dashArrayRef = useRef(dashArray)68 const showMarkerRef = useRef(showMarker)69 const markerColorRef = useRef(markerColor)70 const markerBorderlessRef = useRef(markerBorderless)71 const markerIconRef = useRef(markerIcon)72 const onCompleteRef = useRef(onComplete)73 const autoStartRef = useRef(autoStart)7475 durationRef.current = duration76 pathRef.current = path77 colorRef.current = color78 widthRef.current = width79 opacityRef.current = opacity80 dashArrayRef.current = dashArray81 showMarkerRef.current = showMarker82 markerColorRef.current = markerColor83 markerBorderlessRef.current = markerBorderless84// … 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 |
