-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path大数据立体多边形.html
88 lines (83 loc) · 2.39 KB
/
大数据立体多边形.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=uVo9NXxwYrugBN7lGxWWY0K3MsPw8Nc9"></script>
<script src="https://mapv.baidu.com/gl/examples/static/common.js"></script>
<script src="https://mapv.baidu.com/build/mapv.js"></script>
<script src="https://code.bdstatic.com/npm/mapvgl@1.0.0-beta.54/dist/mapvgl.min.js"></script>
<script src="https://code.bdstatic.com/npm/mapvgl@1.0.0-beta.54/dist/mapvgl.threelayers.min.js"></script>
<style>
html,body,#map_container{
height: 100%;
width: 100%;
padding: 0;
margin: 0;
}
.anchorBL,.BMap_cpyCtrl{
display: none;
}
</style>
</head>
<body>
<div id="map_container">
</div>
<script>
var map = initMap({
tilt: 80,
heading: -45.3,
center: [106.540547,29.564858],
zoom: 17
});
initData();
function initData() {
fetch('https://www.youbaobao.xyz/datav-res/examples/chongqing.json')
.then(res => res.json())
.then(res => {
var data = res;
var polygons = [];
var len = data.length;
for (var i = 0; i < len; i++) {
var line = data[i];
var polygon = [];
var pt = [line[1] * 512, line[2] * 512];
for (var j = 3; j < line.length; j += 2) {
pt[0] += line[j] / 100 / 2;
pt[1] += line[j + 1] / 100 / 2;
polygon.push([pt[0], pt[1]]);
}
polygons.push({
geometry: {
type: 'Polygon',
coordinates: [polygon]
},
properties: {
height: line[0] / 2
}
});
}
setData(polygons);
});
}
function setData(data) {
console.log(data);
var view = new mapvgl.View({
map: map
});
var shaperLayer = new mapvgl.ShapeLayer({
color: 'rgb(0, 255, 255)',
blend: 'lighter',
// style: 'normal',
// style: 'gradual',
style: 'windowAnimation',
opacity: 1.0, // 透明度
riseTime: 2000, // 楼房升起动画
});
view.addLayer(shaperLayer);
shaperLayer.setData(data);
}
</script>
</body>
</html>