-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.html
More file actions
157 lines (132 loc) · 4.61 KB
/
testing.html
File metadata and controls
157 lines (132 loc) · 4.61 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EpiPen Locator</title>
<!-- Leaflet CSS -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine@3.2.12/dist/leaflet-routing-machine.css" />
<style>
body {
margin: 0;
padding: 0;
display: flex;
height: 100vh;
}
/* Left sidebar with images */
.sidebar {
width: 25%;
background-color: #f8f9fa;
padding: 15px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 15px;
box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}
.sidebar h2 {
font-size: 18px;
margin-bottom: 10px;
text-align: center;
}
.sidebar img {
width: 100%;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
/* Map container */
.map-container {
flex: 1;
position: relative;
}
#map {
height: 100%;
width: 100%;
}
.custom-popup .leaflet-popup-content-wrapper {
background: white;
border-radius: 20px;
box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}
.custom-popup .leaflet-popup-content {
margin: 13px 19px;
font-size: 16px;
}
</style>
</head>
<body>
<!-- Left sidebar with images -->
<div class="sidebar">
<img src="./images/1_step.png" alt="Step 1">
<img src="./images/2_step.png" alt="Step 2">
<img src="./images/3_step.png" alt="Step 3">
</div>
<!-- Map container -->
<div class="map-container">
<div id="map"></div>
</div>
<!-- Leaflet JS -->
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet-routing-machine@3.2.12/dist/leaflet-routing-machine.js"></script>
<!-- JavaScript for Map -->
<script>
let map;
let userMarker = null;
let routingControl = null;
// Custom markers
const blueIcon = L.icon({
iconUrl: 'https://cdn.rawgit.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-blue.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
const redIcon = L.icon({
iconUrl: 'https://cdn.rawgit.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
// Initialize map
function initMap() {
map = L.map('map').setView([38.0325, -78.5097], 16);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
loadFacilitiesFromFile();
}
// Load facilities from TXT file
async function loadFacilitiesFromFile() {
try {
const response = await fetch('facilities.txt');
const text = await response.text();
const lines = text.split('\n').filter(line =>
line.trim() && !line.startsWith('#')
);
facilities = lines.map(line => {
const parts = line.split(',');
return {
lat: parseFloat(parts[0]),
lng: parseFloat(parts[1]),
type: parts[2] || 'EpiPen'
};
});
addFacilityMarkers();
getUserLocation();
} catch (error) {
console.error('Error loading facilities file:', error);
useFallbackFacilities();
}
}
// Fallback with sample data if file loading fails
function useFallbackFacilities() {
// Same as previous implementation
}
initMap();
</script>
</body>
</html>