Skip to main content

3DGS service flight positioning

When loading the 3DGS service in the map, the perspective of the model can be automatically positioned to avoid the situation where the model cannot be seen or found after loading.

show

   <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>3DGS service flight positioning</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%;
}

.btn-group {
position: absolute;
top: 20px;
left: 20px;
z-index: 999;
}
</style>
<script src="https://delivery.mapmost.com/cdn/sdk/webgl/v9.16.0/mapmost-webgl-min.js"></script>
</head>
<body>
<div id="map"></div>
<div class="btn-group">
<button onClick="addLayer()">Load data</button>
</div>
<script>
var map = new mapmost.Map({
container: 'map',
style: "<your style url>",
center: [120.74449559193792, 31.30775326748954],
zoom: 16,
pitch: 60,
userId: '***', // Authorization code
});

map.on('load', function () {
map.addLayer(
{
id: 'gs-3d-layer',
type: "MMGS",
url: 'http://***/mmgs.json',
callback: function (group, layer) {
layer.flyToSelf({
// "bearing": 30, // azimuth angle
// "pitch": 60, // pitch angle
// "duration": 3000, // flight time
});
},
}
)
})
</script>
</body>
</html>