Add a video
Display a video on top of a satellite raster baselayer. Click the map to play and pause the video.
Note
If you want to test this example, edit it in JSFiddle or CodePen and replace the "YOUR-OWN-API-KEY" and "YOUR-OWN-VPM-ID" placeholders with your actual api key and vpm id.<!DOCTYPE html><html><head><meta charset="utf-8" /><title>Add a video</title><meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /><script src="https://unpkg.com/unl-map-js@0.1.5/lib/unl-map-js.js"></script><link href="https://unpkg.com/unl-map-js@0.1.5/lib/unl-map-js.css" rel="stylesheet" /><linkhref="https://unpkg.com/maplibre-gl@2.1.9/dist/maplibre-gl.css"rel="stylesheet"/><style> body { margin: 0; padding: 0; } #map { position: absolute; top: 0; bottom: 0; width: 100%; }</style></head><body><div id="map"></div><script>var videoStyle = {version: 8,sources: {satellite: {type: "raster",url: "https://api.maptiler.com/tiles/satellite/tiles.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL",tileSize: 256,},video: {type: "video",urls: ["https://static-assets.mapbox.com/mapbox-gl-js/drone.mp4","https://static-assets.mapbox.com/mapbox-gl-js/drone.webm",],coordinates: [[-122.51596391201019, 37.56238816766053],[-122.51467645168304, 37.56410183312965],[-122.51309394836426, 37.563391708549425],[-122.51423120498657, 37.56161849366671],],},},layers: [{id: "background",type: "background",paint: {"background-color": "rgb(4,7,14)",},},{id: "satellite",type: "raster",source: "satellite",},{id: "video",type: "raster",source: "video",},],}; var map = new UnlSdk.Map({container: "map",apiKey: "YOUR-OWN-API-KEY",vpmId: "YOUR-OWN-VPM-ID",minZoom: 14,zoom: 17,center: [-122.514426, 37.562984],bearing: -96,style: videoStyle,}); var playingVideo = true; map.on("click", function () {playingVideo = !playingVideo; if (playingVideo) map.getSource("video").play();else map.getSource("video").pause();});</script> </body></html>