84 lines
2.9 KiB
HTML
84 lines
2.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>TLT Location Finder</title>
|
|
<style>
|
|
#map {
|
|
height: 1000px;
|
|
width: 100%;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<picture>
|
|
<img src="velendeulogo.png" alt="velendeulogo" style="width:auto";>
|
|
</picture>
|
|
<h2>TLT Location Finder</h2>
|
|
<form id="search-form">
|
|
<label for="bus-id">Enter TAK:</label>
|
|
<input type="text" id="bus-id" name="bus-id">
|
|
<button type="submit">Search</button>
|
|
</form>
|
|
<form id="recievedData">
|
|
<p id="type">Type: UNFETCHED</p>
|
|
<p id="line">Current line: UNFETCHED</p>
|
|
<p id="lat">Latitude: UNFETCHED</p>
|
|
<p id="long">Longitude: UNFETCHED</p>
|
|
<p id="latlong">Coordinates (Merged): UNFETCHED</p>
|
|
<p id="tak">TAK: UNFETCHED</p>
|
|
<p id="vehicleInfo">Vehicle info: UNFETCHED</p>
|
|
</form>
|
|
|
|
<div id="map"></div>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.js"></script>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.css" />
|
|
|
|
<script src="/socket.io/socket.io.js"></script>
|
|
<script>
|
|
var socket = io();
|
|
|
|
// Stuff for the map
|
|
var map = L.map('map').setView([59.4370, 24.7536], 12);
|
|
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
}).addTo(map);
|
|
|
|
// Function to handle form submission
|
|
document.getElementById('search-form').addEventListener('submit', function (event) {
|
|
event.preventDefault();
|
|
var tak = document.getElementById('bus-id').value.trim();
|
|
socket.emit('takSearch', tak);
|
|
});
|
|
socket.on('takResults', (typeR, lineR, latR, longR, takR, latlongR, vehicleTypeR) => {
|
|
console.log("Datafetch success");
|
|
console.log("Transport Type:", typeR);
|
|
console.log("Line Number:", lineR);
|
|
console.log("Latitude:", latR);
|
|
console.log("Longitude:", longR);
|
|
console.log("Lat long MERGE:", latlongR);
|
|
console.log("TAK:", takR);
|
|
console.log("Vehicle info: ", vehicleTypeR);
|
|
document.getElementById("type").innerHTML = "Type:" + typeR;
|
|
document.getElementById("line").innerHTML = "Current line:" + lineR;
|
|
document.getElementById("lat").innerHTML = "Latitude:" + latR;
|
|
document.getElementById("long").innerHTML = "Longitude:" + longR;
|
|
document.getElementById("latlong").innerHTML = "Coordinates (Merged):" + latlongR;
|
|
document.getElementById("tak").innerHTML = "TAK:" + takR;
|
|
document.getElementById("vehicleInfo").innerHTML = "Vehicle info:" + vehicleTypeR;
|
|
/*// Add markers for each bus location
|
|
data.forEach(function(bus) {
|
|
L.marker([bus.latitude, bus.longitude]).addTo(map);
|
|
});*/
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html> |