biketrack-plainjs/map.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-07-18 15:18:07 +02:00
2022-07-19 16:26:53 +02:00
var map = L.map('map').setView([49.41607523, 8.672200499], 19);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 44,
attribution: '© OpenStreetMap'
}).addTo(map);
// helper function for displayRoute()
async function prepare(){
var allcoordinates = getAllCoordinates('coordinates');
return allcoordinates;
}
async function displayRoute() {
var allcoordinates = await prepare();
console.log(allcoordinates);
//var marker = L.marker([49.41607523,8.67220049]).addTo(map);
var polyline = L.polyline(allcoordinates, {color: 'red'}).addTo(map);
2022-07-22 13:03:03 +02:00
var currentime = await getCurrentTime()
var ul = document.getElementById("list");
var li = document.createElement("li");
li.appendChild(document.createTextNode("Last travelled route on: " +currentime+""));
ul.appendChild(li);
map.fitBounds(polyline.getBounds());
map.fitBounds(polyline.getBounds())
return currentime
2022-07-19 16:26:53 +02:00
}
async function showBike(){
var current_cord = await getCurrentCoordinate()
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
L.marker(current_cord).addTo(map)
.bindPopup(' Your BIKE!')
.openPopup();
}