forked from mansiruhil13/Bobble-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ambtracker.html
90 lines (79 loc) · 2.79 KB
/
ambtracker.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ambulance GPS Tracking System</title>
<style>
/* Full page styles */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
/* Map container */
#map {
height: 90%;
width: 100%;
}
/* Header styles */
h1 {
text-align: center;
background-color: #4CAF50;
color: white;
padding: 15px;
margin: 0;
}
/* Add a loading spinner for the map */
#loadingSpinner {
display: none; /* Hidden by default */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1000;
}
</style>
<!-- Include the Google Maps JavaScript API -->
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCKR3agIMLtauzDhz4fCu3heww0BV_81H4" async defer></script>
</head>
<body>
<!-- Header -->
<h1>Ambulance GPS Tracking System</h1>
<!-- Map container -->
<div id="map"></div>
<!-- Loading Spinner -->
<div id="loadingSpinner">Loading...</div>
<!-- Script to load the map and track ambulance -->
<script>
let map, marker;
// Initial position of the ambulance (example coordinates)
const ambulancePosition = { lat: 37.7749, lng: -122.4194 }; // San Francisco
// Function to initialize the map
function initMap() {
loadingSpinner.style.display = "block"; // Show spinner
map = new google.maps.Map(document.getElementById('map'), {
center: ambulancePosition,
zoom: 15
});
loadingSpinner.style.display = "none"; // Hide spinner after map is loaded
marker = new google.maps.Marker({
position: ambulancePosition,
map: map,
title: 'Ambulance Location'
});
setInterval(updateAmbulancePosition, 5000);
}
// Function to simulate the update of the ambulance's GPS position
function updateAmbulancePosition() {
const newLat = ambulancePosition.lat + (Math.random() * 0.001 - 0.0005);
const newLng = ambulancePosition.lng + (Math.random() * 0.001 - 0.0005);
const newPosition = { lat: newLat, lng: newLng };
marker.setPosition(newPosition);
map.setCenter(newPosition);
}
// Initialize the map when the window loads
window.onload = initMap;
</script>
</body>
</html>