-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndex.html
executable file
·166 lines (152 loc) · 6.08 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<html>
<head>
<title>Примеры. Тепловая карта.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="https://yandex.st/bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
html, body, .hero-unit {
min-height: 100%;
height: 100%;
margin: 0px;
}
#YMapsID {
width: 900px;
height: 500px;
}
#YMapsCode {
width: 880px;
}
</style>
<script src="https://api-maps.yandex.ru/2.1/?lang=ru-RU" type="text/javascript"></script>
<script src="heatmap.min.js" type="text/javascript"></script>
<script src="data.js" type="text/javascript"></script>
<script type="text/javascript">
var currentPoint = [50.453322, 30.516074];
ymaps.ready(function () {
var map = new ymaps.Map('YMapsID', {
center: currentPoint,
controls: ['zoomControl', 'typeSelector', 'fullscreenControl'],
zoom: 12, type: 'yandex#map'
}),
buttons = {
dissipating: new ymaps.control.Button({
data: {
content: 'Toggle dissipating'
},
options: {
selectOnClick: false,
maxWidth: 150
}
}),
opacity: new ymaps.control.Button({
data: {
content: 'Change opacity'
},
options: {
selectOnClick: false,
maxWidth: 150
}
}),
radius: new ymaps.control.Button({
data: {
content: 'Change radius'
},
options: {
selectOnClick: false,
maxWidth: 150
}
}),
gradient: new ymaps.control.Button({
data: {
content: 'Reverse gradient'
},
options: {
selectOnClick: false,
maxWidth: 150
}
}),
heatmap: new ymaps.control.Button({
data: {
content: 'Toggle Heatmap'
},
options: {
selectOnClick: false,
maxWidth: 150
}
})
},
gradients = [{
0.1: 'rgba(128, 255, 0, 0.7)',
0.2: 'rgba(255, 255, 0, 0.8)',
0.7: 'rgba(234, 72, 58, 0.9)',
1.0: 'rgba(162, 36, 25, 1)'
}, {
0.1: 'rgba(162, 36, 25, 0.7)',
0.2: 'rgba(234, 72, 58, 0.8)',
0.7: 'rgba(255, 255, 0, 0.9)',
1.0: 'rgba(128, 255, 0, 1)'
}],
radiuses = [5, 10, 20, 30],
opacities = [0.4, 0.6, 0.8, 1];
ymaps.modules.require(['Heatmap'], function (Heatmap) {
var heatmap = new Heatmap(data, {
gradient: gradients[0],
radius: radiuses[1],
opacity: opacities[2]
});
heatmap.setMap(map);
map.geoObjects.add(
new ymaps.Placemark(currentPoint,
{iconContent: 'Center'},
{preset: 'twirl#greenStretchyIcon'}
)
);
buttons.dissipating.events.add('press', function () {
heatmap.options.set(
'dissipating', !heatmap.options.get('dissipating')
);
});
buttons.opacity.events.add('press', function () {
var current = heatmap.options.get('opacity'),
index = opacities.indexOf(current);
heatmap.options.set(
'opacity', opacities[++index == opacities.length ? 0 : index]
);
});
buttons.radius.events.add('press', function () {
var current = heatmap.options.get('radius'),
index = radiuses.indexOf(current);
heatmap.options.set(
'radius', radiuses[++index == radiuses.length ? 0 : index]
);
});
buttons.gradient.events.add('press', function () {
var current = heatmap.options.get('gradient');
heatmap.options.set(
'gradient', current == gradients[0] ? gradients[1] : gradients[0]
);
});
buttons.heatmap.events.add('press', function () {
heatmap.setMap(
heatmap.getMap() ? null : map
);
});
for (var key in buttons) {
if (buttons.hasOwnProperty(key)) {
map.controls.add(buttons[key]);
}
}
});
});
</script>
</head>
<body>
<div class="hero-unit">
<div class="container">
<p>Yandex Maps API <a href="https://github.com/yandex/mapsapi-heatmap">Heatmap Module</a></p>
<div id="YMapsID"></div>
</div>
</div>
</body>
</html>