-
Notifications
You must be signed in to change notification settings - Fork 236
Expand file tree
/
Copy pathdriver.html
More file actions
85 lines (75 loc) · 3.01 KB
/
Copy pathdriver.html
File metadata and controls
85 lines (75 loc) · 3.01 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Driver Dashboard</title>
<link rel="stylesheet" href="driver.css">
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCKR3agIMLtauzDhz4fCu3heww0BV_81H4"></script>
<style>
#map {
width: 100%;
height: 320px;
display: none;
margin-bottom: 20px; /* Hidden initially */
}
#driverImage {
width: 100%;
height: 320px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="dashboard-container">
<h1>Welcome, <span id="driverName">Driver ___</span></h1>
<p id="status">You are currently: <strong id="availability">OFF DUTY</strong></p>
<!-- Driver Image -->
<img src="img.jpeg" alt="Driver Image" id="driverImage">
<!-- Google Map -->
<div id="map"></div>
<div class="toggle-container">
<label class="switch">
<input type="checkbox" id="availabilityToggle">
<span class="slider"></span>
</label>
<p>Availability</p>
</div>
</div>
<script>
const availabilityToggle = document.getElementById('availabilityToggle');
const availabilityText = document.getElementById('availability');
const statusText = document.getElementById('status');
const driverName = document.getElementById('driverName');
const driverImage = document.getElementById('driverImage');
const mapElement = document.getElementById('map');
// Initialize the map
function initMap() {
const mapOptions = {
zoom: 14,
center: { lat: 37.7749, lng: -122.4194 } // Example location: San Francisco
};
const map = new google.maps.Map(mapElement, mapOptions);
}
// Set initial values (can be set dynamically later)
driverName.textContent = "XYZ"; // Example driver name
let isAvailable = false;
// Toggle availability function
availabilityToggle.addEventListener('change', () => {
isAvailable = availabilityToggle.checked;
if (isAvailable) {
availabilityText.textContent = "ON DUTY";
statusText.style.color = "green";
driverImage.style.display = "none"; // Hide the image
mapElement.style.display = "block"; // Show the map
initMap(); // Initialize the map
} else {
availabilityText.textContent = "OFF DUTY";
statusText.style.color = "red";
mapElement.style.display = "none"; // Hide the map
driverImage.style.display = "block"; // Show the image
}
});
</script>
</body>
</html>