Skip to main content

Load real-time video

Load real-time video on the map, support hls video stream and flv video stream.

show
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Loading real-time video</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"/>
<style>
body {
margin: 0;
padding: 0;
}

#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
<script src="https://delivery.mapmost.com/cdn/sdk/webgl/v9.16.0/mapmost-webgl-min.js"></script>
</head>
<body>
<div id="map"></div>
<script>

var map = new mapmost.Map({
container: 'map',
style: "<your style url>",
bearing: 178.6041151348021, // Map azimuth
center: [113.31938586408427, 23.137514162214188], // Map center point
pitch: 83, // map pitch angle
zoom: 18, // Map zoom level
});

map.on('load', function () {

//Model resources
let models_obj = ["SM_AotiOut"].map(item => ({
type: 'glb',
url: './example/models/' + item + '.glb',
}));

//Model layer parameters
let options = {
id: 'model_id', // model id
models: models_obj, // The model resources defined above
type: 'model',
center: [113.31936068187213, 23.140535719438375, 8], // model center point
};

//Add the model to the map
map.addLayer(options);

//Add stereoscopic video
map.addOnlineVideo({
id: 'onlineVideo', // Similar to layer id, needs to be unique
type: 'flv', //Video file type
coordinates: [ // Array of corner point coordinates: starting from the upper left corner of the video, clockwise;
[113.3194345936019, 23.139526879770628, 32.81843538513205],
[113.31928603523475, 23.139526879769893, 32.73495036936757],
[113.31928666027697, 23.13952687977152, 26.972057153821822],
[113.31943325632825, 23.139525259675093, 26.98955575125059]
],
url: '<your video url>' // video url
});

map.on('click', function () {
//remove video
map.removeOnlineVideo('onlineVideo')
})
})

</script>
</body>
</html>