-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
221 lines (194 loc) · 7.25 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE html>
<html>
<head>
<title>Kultūros Naktis</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script src="assets/jquery-2.1.1.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="assets/bootstrap-3.1.1.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="assets/bootstrap-theme-3.1.1.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="assets/bootstrap-3.1.1.min.js"></script>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 100% }
#controls {
margin: 7px;
}
#controls .btn {
margin: 5px 5px 0px 0px;
}
#layers { display: none; }
button a, button a:hover, button a:visited { color: white; }
input[type='range'] {
border-radius: 5px;
box-shadow: inset 0 0 5px #333;
background-color: #428bca;
height: 16px;
vertical-align: middle;
display: inline-block;
width: 140px;
}
.modal-content {
padding: 5px;
}
#title {
font-weight: bold;
font-size: larger;
}
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBZaFMwQygdgVYh8XNKbSmNwWCxDnsZYQg">
</script>
<script type="text/javascript">
var map = null;
var disabledTypes = [];
var dataFile = {
2014: "2014",
2015: "2015"
}[location.search.split('?')[1]] || "2015";
$(function() {
createMap();
createPopover();
createSlider();
createLayers();
});
function createMap() {
var vilnius = new google.maps.LatLng(54.6845267, 25.2725436);
var mapOptions = {
zoom: 14,
center: vilnius
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
homeControlDiv = document.getElementById("controls");
map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
map.setCenter(initialLocation);
}, function() {});
}
}
function createPopover() {
$('#visible-layers').popover({
container: "body",
placement: "bottom",
html : true,
content: function() {
return $('#layers').html();
}
});
$('body').on('click', '.layer', function (event) {
var element = $(event.target)
var name = element.data("name")
$(element).toggleClass("active");
// When popover is closed, its DOM elements are destroyed.
// We have to set correct class for the original, so that
// recreated popover has correct state
$('#layers .layer[data-name="'+name+'"]').toggleClass("active");
map.data.forEach(function(feature) {
var type = feature.getProperty("type")
if (name == type) {
feature.setProperty("disabledByType", !$(element).hasClass("active"));
}
});
});
$('#controls #data-' + dataFile).removeClass('btn-default').addClass('btn-primary');
}
function createLayers() {
map.data.loadGeoJson('data' + dataFile + '.geojson', null, function(data) {
$("#view-from").trigger("change");
});
map.data.addListener('click', function(event) {
$('#modal #title').text(event.feature.getProperty("title"));
$('#modal #time').text(
event.feature.getProperty("from") +
" - " +
event.feature.getProperty("until") +
" val."
);
$('#modal #description').text(event.feature.getProperty("description"));
$('#modal #link').attr("href", event.feature.getProperty("link"));
$('#modal').modal();
});
map.data.setStyle(function(feature) {
var visible = !feature.getProperty('disabled') && !feature.getProperty('disabledByType')
return {
visible: visible,
icon: feature.getProperty("icon")
};
});
}
function createSlider() {
$("#view-from").change(function(evt) {
var eventsStart = 100;
var eventsEnd = 0;
map.data.forEach(function(feature) {
var startsAt = feature.getProperty("fromNumerical");
var endsAt = feature.getProperty("untilNumerical");
if (startsAt < 10) {
startsAt += 24;
}
if (endsAt < 10) {
endsAt += 24;
}
if (startsAt < eventsStart) {
eventsStart = startsAt;
}
if (endsAt > eventsEnd) {
eventsEnd = endsAt;
}
});
var selectedTime = Math.floor(evt.currentTarget.value / 100 * (eventsEnd - eventsStart) + eventsStart);
$("#selected-time").text(selectedTime > 24 ? selectedTime - 24 : selectedTime);
map.data.forEach(function(feature) {
var endsAt = feature.getProperty("untilNumerical")
if (endsAt < 10) {
endsAt += 24;
}
feature.setProperty("disabled", selectedTime > endsAt);
});
});
}
</script>
</head>
<body>
<div id="map-canvas">
</div>
<div id="controls">
<div>
<span>Iki </span><span id="selected-time">18</span><span> h. </span><input id="view-from" type="range" name="points" min="0" max="100">
</div>
<button id="visible-layers" type="button" class="btn btn-primary btn-xs" data-toggle="popover">
Rodomos vietos
</button>
<button type="button" class="btn btn-primary btn-xs">
<a target="_blank" href="https://github.com/lietuvoje/kulturos-naktis">Prisidėk!</a>
</button>
<div>
<a id="data-2014" href="?2014" class="btn btn-default btn-xs" role="button">2014</a>
<a id="data-2015" href="?2015" class="btn btn-default btn-xs" role="button">2015</a>
</div>
</div>
<ul id="layers" class="list-group">
<li class="layer list-group-item active" data-name="dancinghall">Šokiai</li>
<li class="layer list-group-item active" data-name="cinema">Kinas</li>
<li class="layer list-group-item active" data-name="music_live">Gyva muzika</li>
<li class="layer list-group-item active" data-name="theater">Teatrai</li>
<li class="layer list-group-item active" data-name="publicart">Vieša erdvė</li>
<li class="layer list-group-item active" data-name="flag-export">Kita</li>
</ul>
<div id="modal" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<p id="title"></p>
<p id="time"></p>
<p id="description"></p>
<a id="link" href="" target="_blank">Daugiau</a>
</div>
</div>
</div>
</body>
</html>