Skip to main content

3DGS batch singulation

Dynamically create an outer box model of the 3DGS singleton area to achieve the 3DGS singleton effect in the outer bounding box.

show
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title>3DGS batch singulation</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>",
center: [120.74449559193792, 31.30775326748954],
zoom: 15,
pitch: 60,
userId: "***", // Authorization code
});

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

//Load 3DGS service
map.addLayer({
id: "gs-3d-layer",
type: "MMGS",
url: "http://****/3dgs/yuanqu_100km/1/mmgs.json",
depthWrite: true,
});

// Batch singleton
const warmColors = [
"#FF0000", // red
"#00FF00", // green
"#0000FF", // blue
"#FFFF00", // yellow
"#FF00FF", // magenta
"#00FFFF", // cyan
"#FF8000", // orange
"#8000FF", // purple
"#80FF00", // lime green
"#FF0080", // pink
];

Promise.all([
fetch("./data.json").then((res) =>
res.json(),
),
]).then((results) => {
let analysis = new mapmost.ClassifyAnalysis(map);
let data = [];
data = data.concat(
results[0].map((item, index) => {
return {
coordinate: item.contour_4326,
color: warmColors[index % warmColors.length],
opacity: 0.1,
baseHeight: 0,
stretchHeight: item.max_z + 20,
};
}),
);
analysis.analyse(data);
});
})
</script>
</body>

</html>