-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.htm
141 lines (120 loc) · 4.95 KB
/
index.htm
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
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2 id='title'>Σύστημα Έγκαιρης Πρόληψης Πλημμυρικών Φαινομένων</h2>
<p id='demo'>Demo project Μάνδρα Αττικής</p>
<script src="scetch.js"></script>
<p id="time"></p>
<p id="watch"></p>
<div id="map"></div>
<script>
data_time = new Date;
data_hours = data_time.getHours();
data_minutes = data_time.getMinutes();
data_hstring = data_hours.toString();
data_mstring = data_minutes.toString();
document.getElementById('time').innerHTML = 'Data Recieved At '+data_hstring + ' : ' + data_mstring + ' pm';
function rand(){
let random = Math.floor(Math.random() * max_cm);
return random;
}
function findLargest(array){
var largest = 0;
var large_idx = 0;
for (i = 0; i < array.length; i++) {
if (array[i] > largest) {
largest = array[i];
large_idx = i;
}
}
return large_idx;
}
var prefix = 'http://maps.google.com/mapfiles/ms/icons/';
var weather = 'sunny'
var max_cm = 80;
var descr = 'Online';
var display = 'issues'
var map;
var watch_list = [];
var markers = [];
function initMap() {
var simia = [
{ name:"Αικατερίνης 36", lat:38.077227, lng:23.487771, cm:rand() },
{ name:"Αικατερίνης 20", lat:38.076997, lng:23.490283, cm:rand() },
{ name:"Αικατερίνης 2", lat:38.076491, lng:23.493966, cm:rand() },
{ name:"Ρόκκα 14", lat:38.078072, lng:23.494993, cm:rand() },
{ name:"Ρόκκα 28", lat:38.075027, lng:23.496858, cm:rand() },
{ name:"Δημαρχείο", lat:38.073883, lng:23.500301, cm:rand() },
{ name:"Ρόκκα 156", lat:38.072372, lng:23.508611, cm:rand() },
{ name:"Αικατερίνης 48", lat:38.077151, lng:23.482784, cm:rand() },
{ name:"Ελευσίνας - Θηβών 24ο χιλ.", lat:38.079148, lng:23.494307, cm:rand() },
{ name:"Ελευσίνας - Θηβών 20ο χιλ.", lat:38.080391, lng:23.493507, cm:rand() },
{ name:"Ελευσίνας - Θηβών 27ο χιλ.", lat:38.078002, lng:23.499613, cm:rand() },
{ name:"Ελευσίνας - Θηβών 20ο χιλ.", lat:38.080391, lng:23.493507, cm:rand() },
]
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 38.076, lng: 23.496}, //map center
zoom: 16 //init zoom level
});
for(let marker of simia){
if (marker.cm > 50 * max_cm / 100){
if (marker.cm > 70 * max_cm / 100){
suffix = 'purple-dot.png';
descr = 'Fatal Error.'
statistics = marker.cm * max_cm / 100;
watch_list.push(marker);
}else{
suffix = 'yellow-dot.png';
descr = 'Warning.';
statistics = marker.cm * max_cm / 100;
watch_list.push(marker);
}
}else if(marker.cm < 55 * max_cm / 100){
suffix = 'green-dot.png';
descr = 'Normal.';
statistics = marker.cm * max_cm / 100;
}
var map_marker = new google.maps.Marker({
position: {lat:marker.lat, lng:marker.lng},
map: map,
title: marker.name + '\n' + descr + '\n' + statistics + '%',
icon: {
url: prefix + suffix
}
});
markers.push(map_marker);
console.log(watch_list);
console.log(watch_list);
}
let issues = watch_list.length;
let idx = findLargest(watch_list);
let text = document.getElementById('watch').innerHTML = watch_list[idx].name;
document.getElementById('watch').addEventListener('click', function(){
map.setCenter({lat: watch_list[0].lat, lng: watch_list[0].lng});
map.setZoom(17.5);
})
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=&callback=initMap"
async defer></script>
</body>
</html>