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); 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 } 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(); }