-
Notifications
You must be signed in to change notification settings - Fork 1
/
weighted-location.html
105 lines (89 loc) · 2.58 KB
/
weighted-location.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Heatmaps</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
#panel {
position: absolute;
top: 5px;
left: 50%;
margin-left: -180px;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=visualization"></script>
<script>
// Adding 500 Data Points
var map, pointarray, heatmap;
var myWeightedData = [
{location: new google.maps.LatLng(40.922326,-72.637078), weight: 5},
{location: new google.maps.LatLng(40.922326,-72.637078), weight: 5},
{location: new google.maps.LatLng(18.165273,-66.722583), weight: 5},
{location: new google.maps.LatLng(18.393103,-67.180953), weight: 5},
{location: new google.maps.LatLng(18.455913,-67.14578), weight: 5},
new google.maps.LatLng(18.49352,-67.135883)
];
function initialize() {
var mapOptions = {
zoom: 4,
center: new google.maps.LatLng(39.50, -98.35),
mapTypeId: google.maps.MapTypeId.MAP
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
//var pointArray = new google.maps.MVCArray(tamiFluData);
heatmap = new google.maps.visualization.HeatmapLayer({
data: myWeightedData
});
heatmap.setMap(map);
}
function toggleHeatmap() {
heatmap.setMap(heatmap.getMap() ? null : map);
}
function changeGradient() {
var gradient = [
'rgba(0, 255, 255, 0)',
'rgba(0, 255, 255, 1)',
'rgba(0, 191, 255, 1)',
'rgba(0, 127, 255, 1)',
'rgba(0, 63, 255, 1)',
'rgba(0, 0, 255, 1)',
'rgba(0, 0, 223, 1)',
'rgba(0, 0, 191, 1)',
'rgba(0, 0, 159, 1)',
'rgba(0, 0, 127, 1)',
'rgba(63, 0, 91, 1)',
'rgba(127, 0, 63, 1)',
'rgba(191, 0, 31, 1)',
'rgba(255, 0, 0, 1)'
]
heatmap.set('gradient', heatmap.get('gradient') ? null : gradient);
}
function changeRadius() {
heatmap.set('radius', heatmap.get('radius') ? null : 20);
}
function changeOpacity() {
heatmap.set('opacity', heatmap.get('opacity') ? null : 0.2);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="panel">
<button onclick="toggleHeatmap()">Toggle Heatmap</button>
<button onclick="changeGradient()">Change gradient</button>
<button onclick="changeRadius()">Change radius</button>
<button onclick="changeOpacity()">Change opacity</button>
</div>
<div id="map-canvas"></div>
</body>
</html>