Spaces:
Runtime error
Runtime error
File size: 9,584 Bytes
a7ea71f |
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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
<!DOCTYPE html>
<html>
<head>
<title>Geographical Interface</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<style>
#map {
width: 100%;
height: 100vh;
position: absolute;
top: 0;
left: 0;
}
#data-entry-panel {
position: absolute;
top: 10px;
right: 10px;
width: 300px;
background-color: #f8f8f8;
padding: 15px;
border: 1px solid #ddd;
border-radius: 5px;
z-index: 1000;
}
#data-entry-panel label,
#data-entry-panel select,
#data-entry-panel textarea {
display: block;
margin-bottom: 10px;
width: 100%;
}
#data-entry-form button {
display: block;
margin: 0 auto;
padding: 10px 20px;
background-color: orange;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
#data-entry-form button:hover {
background-color: darkorange;
}
/* Additional styles for multi-mode transport options */
#multi-mode-options {
display: none;
margin-top: 10px;
margin-bottom: 10px;
}
/* Point Type Selector styles */
#point-selector {
position: absolute;
top: 10px;
left: 75px;
background-color: #f8f8f8;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
z-index: 1000;
font-size: 16px;
}
</style>
</head>
<body>
<div id="map"></div>
<!-- Point Type Selector on the Left -->
<div id="point-selector">
<p>Select Point Type:</p>
<label style="display: inline-block; margin-right: 10px;">
<input type="radio" name="pointType" value="start" checked>
<span style="color: red;">●</span> Start Point
</label>
<label style="display: inline-block; margin-right: 10px;">
<input type="radio" name="pointType" value="lost">
<span style="color: yellow;">●</span> Getting Lost Point
</label>
<label style="display: inline-block;">
<input type="radio" name="pointType" value="end">
<span style="color: blue;">●</span> End Point
</label>
</div>
<!-- Side Panel -->
<div id="data-entry-panel">
<h3>Enter Data</h3>
<form id="data-entry-form">
<label for="age">Age:</label>
<select id="age">
<option value="0-10">0-10</option>
<option value="11-20">11-20</option>
<option value="21-30">21-30</option>
<option value="31-40">31-40</option>
<option value="41-50">41-50</option>
<option value="51-60">51-60</option>
<option value="61+">61+</option>
</select>
<label for="gender">Gender:</label>
<select id="gender">
<option value="F">Female</option>
<option value="M">Male</option>
<option value="O">Other</option>
<option value="PNTS">Prefer Not To Say</option>
</select>
<label for="transport">Mode of Transport:</label>
<select id="transport" onchange="checkTransportMode()">
<option value="Walk">Walk</option>
<option value="Car">Car</option>
<option value="Bike">Bike</option>
<option value="Train">Train</option>
<option value="Subway">Subway</option>
<option value="Other">Other</option>
<option value="Multi">Multi</option>
</select>
<div id="multi-mode-options">
<p>Select modes used:</p>
<input type="checkbox" id="walk" name="mode" value="Walk">
<label for="walk">Walk</label><br>
<input type="checkbox" id="Train" name="mode" value="Train">
<label for="walk">Train</label><br>
<input type="checkbox" id="Bike" name="mode" value="Bike">
<label for="Bike">Bike</label><br>
<input type="checkbox" id="Subway" name="mode" value="Subway">
<label for="Subway">Subway</label><br>
</div>
<label for="timeOfDay">Time Of Day:</label>
<select id="timeOfDay">
<option value="Morning">Morning</option>
<option value="Afternoon">Afternoon</option>
<option value="Evening">Evening</option>
<option value="Night">Night</option>
</select>
<label for="dayOfWeek">Date (Day of the week):</label>
<select id="dayOfWeek">
<option value="Monday">Monday</option>
<option value="Tuesday">Tuesday</option>
<option value="Wednesday">Wednesday</option>
<option value="Thursday">Thursday</option>
<option value="Friday">Friday</option>
<option value="Saturday">Saturday</option>
<option value="Sunday">Sunday</option>
</select>
<label for="description">Why did you get lost?</label>
<textarea id="description" rows="4"></textarea>
<button type="button" onclick="submitData()">Save</button>
<hr style="margin-top: 15px;">
<p>For a more detailed survey, click the link or scan the QR code:</p>
<a href="https://arcg.is/1GK5jP0" target="_blank">https://arcg.is/1GK5jP0</a>
<br>
<img src="/static/Getting Lost Survey.png" alt="QR Code for Survey" style="margin-top: 10px; width: 50%;">
</div>
</form>
</div>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script>
var openStreetMapLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
});
var openTopoMapLayer = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
attribution: '© OpenTopoMap contributors'
});
var map = L.map('map', {
center: [51.505, -0.09],
zoom: 13,
layers: [openStreetMapLayer]
});
var baseMaps = {
"OpenStreetMap": openStreetMapLayer,
"OpenTopoMap": openTopoMapLayer
};
L.control.layers(baseMaps, null, { position: 'topleft' }).addTo(map);
var clickedLat = null;
var clickedLon = null;
map.on('click', function (e) {
clickedLat = e.latlng.lat;
clickedLon = e.latlng.lng;
var pointType = document.querySelector('input[name="pointType"]:checked').value;
var color;
switch (pointType) {
case 'start':
color = 'red';
break;
case 'lost':
color = 'yellow';
break;
case 'end':
color = 'blue';
break;
}
L.circleMarker([clickedLat, clickedLon], {
color: color,
radius: 5
}).addTo(map);
});
function checkTransportMode() {
var transport = document.getElementById('transport').value;
var multiOptions = document.getElementById('multi-mode-options');
if (transport === 'Multi') {
multiOptions.style.display = 'block';
} else {
multiOptions.style.display = 'none';
}
}
function submitData() {
var age = document.getElementById('age').value;
var gender = document.getElementById('gender').value;
var transport = document.getElementById('transport').value;
var timeOfDay = document.getElementById('timeOfDay').value;
var dayOfWeek = document.getElementById('dayOfWeek').value;
var description = document.getElementById('description').value;
var pointType = document.getElementById('pointType').value;
fetch('/record_data', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
age: age,
gender: gender,
transport: transport,
timeOfDay: timeOfDay,
dayOfWeek: dayOfWeek,
description: description,
lat: clickedLat,
lon: clickedLon,
pointType: pointType
})
})
.then(response => response.json())
.then(data => {
if (data.error) {
alert('Failed to record data: ' + data.error);
} else {
alert(data.message);
}
});
}
</script>
</body>
</html>
|