Skip to content

Instantly share code, notes, and snippets.

@Hirosaji
Last active December 9, 2019 02:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Hirosaji/df99046e6ef94c563a4db521706e0a5a to your computer and use it in GitHub Desktop.
Mapbox GL JS - Movie on Map
# Mapbox GL JS - Movie on Map
license: mit
<!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://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-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": "mapbox://mapbox.satellite",
"tileSize": 256
},
"video": {
"type": "video",
"urls": ["./movie.mp4"],
"coordinates": [
[141.40009394836426, 43.062391708549425],
[141.40123120498657, 43.06061849366671],
[141.40296391201019, 43.06138816766053],
[141.40167645168304, 43.06310183312965]
]
}
},
"layers": [{
"id": "background",
"type": "background",
"paint": {
"background-color": "rgb(4,7,14)"
}
}, {
"id": "satellite",
"type": "raster",
"source": "satellite"
}, {
"id": "video",
"type": "raster",
"source": "video"
}]
};
mapboxgl.accessToken = 'pk.eyJ1IjoiaGlyb3NhamkiLCJhIjoiY2szOWljb210MDJxcjNjcXRwZGF6bmJnMiJ9.gin_FUY4wc61PoNKnUWL5Q';
var map = new mapboxgl.Map({
container: 'map', // container id
minZoom: 14,
zoom: 16,
style: videoStyle, // stylesheet location
center: [141.4015, 43.06175], // starting position [lng, lat]
bearing: -96
});
</script>
</body>
</html>
This file has been truncated, but you can view the full file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment