-
Notifications
You must be signed in to change notification settings - Fork 0
/
police.html
219 lines (186 loc) · 6.15 KB
/
police.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
<!DOCTYPE html>
<html>
<head>
<title>GUI</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
/* CSS styles for the web app */
body, html {
font-family: Arial, sans-serif;
height: 100%;
margin: 0;
padding-bottom: 30vh;
background-color: rgb(36, 36, 36);
}
h1 {
text-align: center;
background-color: rgb(36, 36, 36);
margin: 0;
padding: 20px;
color: white;
}
h1 > span {
background-color: #677aa0;
color: black;
padding: 4px 10px 4px 10px;
border-radius: 10%;
margin-left: 3px;
}
li > a {
font-size: large;
}
.container2 {
padding: 50px;
display: flex;
align-items: stretch;
}
.notifications {
flex-grow: 1;
flex-basis: 30vw;
background-color: #1e335c;
left: 5%;
padding: 20px;
color: #F1F6F9;
border-radius: 20px;
}
.latest-event {
display: none;
position: absolute;
bottom: 0;
height: 40vh;
background-color: rgb(36, 36, 36);
width: 28vw;
border-radius: 20px;
padding: 20px;
}
.notifications h2 {
margin-top: 0;
font-size: 20px;
font-weight: bold;
}
.map-container {
flex-grow: 3;
flex-basis: 60vw;
color: white;
right: 5%;
margin-top: 5px;
margin-left: 20px;
border-radius: 20px;
height: 100vh;
}
.center-heading {
text-align: center;
}
.map-container h2 {
margin-top: 0;
font-size: 20px;
font-weight: bold;
}
.map {
height: 100%;
background-color: #D21312;
margin-bottom: 10px;
}
.a {
color: aliceblue;
}
h2 {
color: white;
}
</style>
</head>
<body>
<h1>Real Time <span>Alert System</span></h1>
<div class="container2">
<div class="notifications">
<h2>Incoming Notifications</h2>
<ul id="notification-list" class="a"></ul>
<div class="latest-event" id="latest-event">
<h1>Latest Event Details</h1>
<div id="infoDiv">
</div>
</div>
</div>
<div class="map-container">
<div id="map" class="map"></div>
</div>
</div>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCQFtmx3sNQeX9atnTJcTAFE_4RfetffP4&callback=initMap" async defer></script>
<script>
// JavaScript code for Google Maps integration and live notifications
function initMap() {
// Initialize the map
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 28.6139, lng: 77.2090}, // Default center coordinates (Delhi)
zoom: 12
});
// Simulate incoming notifications
var notificationList = document.getElementById('notification-list');
var notifications = [
'A car has a crash warning on 5th and Market',
'A car has a crash warning on 6th and Market',
'There is a gas leak detected',
'A car has overspeeded on Cross St.',
];
setInterval(function() {
// Generate a random notification
var randomIndex = Math.floor(Math.random() * notifications.length);
var notification = notifications[randomIndex];
// Create a new list item
var listItem = document.createElement('li');
var link = document.createElement('a');
link.href = '#'; // Set the href attribute to "#" for now
// Generate random coordinates within New Delhi boundaries
const minLat = 28.4089;
const maxLat = 28.7041;
const minLng = 77.1025;
const maxLng = 77.3300;
const randomLat = Math.random() * (maxLat - minLat) + minLat;
const randomLng = Math.random() * (maxLng - minLng) + minLng;
// Add a click event listener to the hyperlink
link.addEventListener('click', function() {
// Pan the map to the random location
map.panTo({ lat: randomLat, lng: randomLng });
map.setZoom(15); // Zoom in for better visibility
// Create a new div to display the coordinates
var coordinatesDiv = document.createElement('div');
coordinatesDiv.textContent = 'Coordinates: ' + randomLat + ', ' + randomLng;
// Append the coordinates div to the notifications section
listItem.appendChild(coordinatesDiv);
var latestEventDiv = document.getElementById("latest-event");
latestEventDiv.style.display = "block";
var infoDiv = document.getElementById("infoDiv");
latestEventDiv.appendChild(infoDiv);
infoDiv.innerHTML = "";
var name = document.createElement('h3');
name.textContent = "John Doe";//add some js here to get names randomly from some list
var licensePlate = document.createElement('p');
licensePlate.textContent = "UP15AB6969" //same thing
var address = document.createElement('p');
address.textContent = "Chandni Chowk";//hmm
var contactNumber = document.createElement('p');
contactNumber.textContent = "9267495823";// all the best
var emergencyContactNumber = document.createElement('p');
emergencyContactNumber.textContent = "420420420";// you got this
infoDiv.appendChild(name);
infoDiv.appendChild(licensePlate);
infoDiv.appendChild(address);
infoDiv.appendChild(contactNumber);
infoDiv.appendChild(emergencyContactNumber);
});
// Set the text content of the hyperlink
link.textContent = notification;
// Append the hyperlink to the list item
listItem.appendChild(link);
// Add the new list item to the notification list
notificationList.appendChild(listItem);
// Remove the oldest notification if there are more than 5 notifications
if (notificationList.children.length > 5) {
notificationList.removeChild(notificationList.children[0]);
}
}, 3000); // Simulate a new notification every 3 seconds
}
</script>
</body>
</html>