3D弧线图
支持在地图上加载3D弧线图。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>加载3D弧线图</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.2.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.7154990234572, 31.34233273104215],
zoom: 13.42,
pitch: 73.53,
bearing: 25.60,
userId: '***', // 授权码
});
map.on('load', function () {
fetch("./bart-segments.json")
.then((res) => res.json())
.then((response) => {
let data = response.map((da) => {
da.from.color = rgb();
da.to.color = rgb();
return da;
});
// 添加弧线
map.addLayer({
id: "arc-demo",
type: "arc",
data: data,
lineWidth: 20, // 弧线宽度
});
});
})
//rgb颜色随机
function rgb() {
const r = Math.floor(Math.random() * 256);
const g = Math.floor(Math.random() * 256);
const b = Math.floor(Math.random() * 256);
return `rgb(${r},${g},${b})`;
}
</script>
</body>
</html>