-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.html
127 lines (105 loc) · 3.92 KB
/
index.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
html,body{
margin:0px;
height:100%;
width: 100%;
}
#map { width: 100%; height: 100%; background-color : #000;}
</style>
</head>
<script src="js/heatmap.js"></script>
<script src="js/three.js"></script>
<script src="js/TrackballControls.js"></script>
<link type="text/css" rel="stylesheet" href="css/maptalks.css">
<script type="text/javascript" src="js/maptalks.min.js"></script>
<script type="text/javascript" src="js/maptalks.three.js"></script>
<script>
var camera, scene, renderer,container,controls;
window.onload = function()
{
var heatmapInstance = h337.create({
// only container is required, the rest will be defaults
container: document.querySelector('.heatmap')
});
// now generate some random data
var points = [];
var max = 0;
var width = 256;
var height = 256;
var len = 20;
while (len--) {
var val = Math.floor(Math.random()*100);
max = Math.max(max, val);
var point = {
x: Math.floor(Math.random()*width),
y: Math.floor(Math.random()*height),
value: val
};
points.push(point);
}
// heatmap data format
var data = {
max: max,
data: points
};
// if you have a set of datapoints always use setData instead of addData
// for data initialization
heatmapInstance.setData(data);
var map = new maptalks.Map("map",{
center : [13.416935229170008, 52.529564137540376],
zoom : 15,
fog : false,
maxPitch:60,
pitch : 60,
centerCross : false,
doubleClickZoom : false,
attribution : null,
baseLayer : new maptalks.TileLayer('tile',{
'urlTemplate' : 'https://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}.png',
'subdomains' : ['a','b','c','d']
})
});
var threeLayer = new maptalks.ThreeLayer('t', {
forceRenderOnMoving : true,
forceRenderOnRotating : true
}).addTo(map);
let planeLoaded = false;
threeLayer.prepareToDraw = function (gl, scene, camera)
{
var me = this;
var light = new THREE.DirectionalLight( 0xffffff );
light.position.set( 0, 0, 1 );
scene.add( light );
var geometry = new THREE.PlaneGeometry( 0, 0,255,255 );
let geolen = geometry.vertices.length;
var mdata ;
for(let i = 0; i<geolen; i++)
{
geometry.vertices[i].z = heatmapInstance.getValueAt({ x:i%256, y:Math.trunc(i/256) }) /(256*2);
}
let texture = new THREE.CanvasTexture( heatmapInstance._renderer.canvas );
var material = new THREE.MeshBasicMaterial( { map: texture, transparent: true , side :THREE.DoubleSide , depthTest :true} ) ;
var plane = new THREE.Mesh( geometry, material );
//plane.rotateX( - Math.PI / 2 );
plane.scale.set(10, 10, 10);
var v = threeLayer.coordinateToVector3(new maptalks.Coordinate(map.getCenter()));
plane.position.x = v.x;
plane.position.y = v.y;
plane.position.z = v.z;
scene.add( plane );
planeLoaded = true;
};
}
</script>
<body>
<div class="heatmap" style="width: 256px;height: 256px;display: none"></div>
<div id="map"></div>
</body>
</html>