Atlaslog
Atlaslog / Leaflet / API reference / VideoOverlay
Leaflet · API reference

VideoOverlay

Quick answer

L.videoOverlay plays a video across a geographic bounds rectangle and accepts one URL, a list of format alternatives or an existing video element. It inherits image overlay geometry handling and adds autoplay, loop, muting and aspect ratio options. Videos respect pane stacking, so they can sit below or above vector layers.

Last verified 2026-11-03 · Leaflet 1.9.4 · Cite this page
L.videoOverlay( video , bounds , options ) → VideoOverlay
Key points
Example
var bounds = [[39.895, 116.378], [39.920, 116.405]];

var video = L.videoOverlay(
  ['/media/flow.webm', '/media/flow.mp4'],
  bounds,
  { opacity: 0.75, autoplay: true, loop: true, muted: true }
).addTo(map);

/* 浏览器允许静音自动播放,带声音的 autoplay 会被拦截 */
var el = video.getElement();
el.muted = true;
el.play().catch(function () {
  console.warn('自动播放被拦截,等待用户交互');
});

document.getElementById('toggle').addEventListener('click', function () {
  el.paused ? el.play() : el.pause();
});
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). VideoOverlay. https://www.jingweizhi.com/en/leaflet/api/video-overlay.html (accessed 2026-11-03).