3DTiles淹没分析
在3DTiles场景中进行淹没分析可视化。


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>3DTiles淹没分析</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;
}
</style>
<script src="https://delivery.mapmost.com/cdn/sdk/webgl/v9.3.0/mapmost-webgl-min.js"></script>
</head>
<body>
<div id="map"></div>
<div class="btn-group">
<button onClick="add()">淹没分析</button>
<button onClick="remove()">移除</button>
</div>
<script>
var map = new mapmost.Map({
container: 'map',
style: "<your style url>",
center: [120.74449559193792, 31.30775326748954],
zoom: 16,
pitch: 60,
userId: '***', // 授权码
});
let analysis;
let tileLayer;
let modelGroup;
map.on('load', function () {
const TILESET_URL = "<your 3dtiles url>";
map.addLayer(
{
id: 'tile-3d-layer',
type: "3DTiles",
data: TILESET_URL,
callback: function (group, layer) {
tileLayer = layer;
modelGroup = group;
}
}
)
})
function add() {
analysis = new mapmost.FloodAnalysis(tileLayer);
let polygon = [
[120.74091493906315, 31.309723842354217],
[120.74462296468971, 31.311393233066624],
[120.74484083816549, 31.30670598817069],
[120.74227073726502, 31.306037256905938],
[120.74091493906315, 31.309723842354217]];
analysis.analyse({
models: modelGroup,
minHeight: 0,
maxHeight: 50,
startColor: "#07f5ff",
endColor: "#f27d06",
speed: 5,
colorMix: 0.6,
// range: polygon
});
}
function remove() {
analysis.clear()
}
</script>
</body>
</html>