跳到主要内容
版本:9.8.0-beta

压平分析

支持对三维模型和倾斜模型进行压平分析。

show
   <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>压平分析</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.8.0-beta/mapmost-webgl-min.js"></script>
</head>
<body>
<div id="map"></div>
<div class="btn-group">
<button onclick="allFlatten()">全部压平</button>
<button onclick="partFlatten()">区域压平</button>
<button onclick="remove()">清除压平</button>
</div>
<script>
var map = new mapmost.Map({
container: 'map',
style: "<your style url>",
center: [120.7497180851966,31.30737065488684],
zoom: 18,
userId: '***', // 授权码
});

let analysis;
map.on('load', function () {

map.addLayer({
id: 'tile-3d-layer',
type: '3DTiles',
data: '<your 3DTiles url>',
});

analysis = new mapmost.FlattenAnalysis(map.getLayer('tile-3d-layer'));

})

// 全部区域压平
function allFlatten() {
analysis.analyse({ height: 3 });
}

// 部分区域压平
function partFlatten() {
let polygon = [
[120.74949064445497, 31.307147554202416, 0],
[120.74994428630578, 31.307136373753124, 0],
[120.74996754999182, 31.306815866978482, 0],
[120.74950809221758, 31.306810897872666, 0]
];

analysis.analyse({
height: 3, // 模型压平的最终高度
polygons: [polygon], // 模型压平坐标范围
});
}

// 清除
function remove() {
analysis.clear()
}

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