Video

Add georeferenced video overlays to your maps with playback controls.

Installation

First, make sure you have the base map component installed:

npx shadcn@latest add https://www.terrae.dev/map.json

Then install the video layer component:

npx shadcn@latest add https://www.terrae.dev/raster-video.json

Use the useVideoControl hook to control video playback with play, pause, and toggle functions.

Properties

PropertyTypeDefaultDescription
idstringrequiredUnique identifier for the video layer
urlsstring[]requiredArray of video URLs (provide multiple formats)
coordinates[[number, number], ...]requiredFour corner coordinates [topLeft, topRight, bottomRight, bottomLeft]
opacitynumber1Video opacity (0-1)
autoplaybooleanfalseAuto-play video on load
loopbooleantrueLoop video playback
mutedbooleantrueMute video audio

Playback Control Hook

Use the useVideoControl hook to control video playback:

import { useVideoControl } from "@/registry/map";

function VideoControls() {
  const { play, pause, toggle, isPlaying } = useVideoControl("video-id");

  return (
    <button onClick={toggle}>
      {isPlaying ? "Pause" : "Play"}
    </button>
  );
}

Coordinate Format

The coordinates array must contain exactly four corner points in this order:

IndexPositionDescription
0Top LeftNorthwest corner [longitude, latitude]
1Top RightNortheast corner [longitude, latitude]
2Bottom RightSoutheast corner [longitude, latitude]
3Bottom LeftSouthwest corner [longitude, latitude]

Video Format Support

FormatBrowser SupportNotes
MP4 (H.264)All browsersWidely supported, recommended as fallback
WebM (VP8/VP9)Chrome, Firefox, EdgeBetter compression, preferred for web

Provide multiple formats for browser compatibility. Videos should be optimized for web playback with appropriate compression and resolution.

Important Notes

  • Videos must be hosted on a web server accessible to the browser
  • CORS headers must be properly configured on the video server
  • Video playback is affected by user's internet connection speed
  • Autoplay may be blocked by browsers depending on user settings
  • Keep videos muted by default to avoid autoplay issues