40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
let map;
|
|
let marker;
|
|
|
|
async function loadConfig() {
|
|
const res = await fetch("./location.json");
|
|
return await res.json();
|
|
}
|
|
|
|
function initMap(lat, lng) {
|
|
map = L.map('map').setView([lat, lng], 13);
|
|
|
|
L.tileLayer('https://tiles.tservic.es/{z}/{x}/{y}.png', {
|
|
attribution: '© OpenStreetMap © <a href="https://tile.openstreetmap.de" target="_blank">tile.openstreetmap.de</a> - via tiles.tservic.es',
|
|
subdomains: 'abcd',
|
|
maxZoom: 19
|
|
}).addTo(map);
|
|
|
|
marker = L.marker([lat, lng]).addTo(map);
|
|
}
|
|
|
|
function setLinks(lat, lng) {
|
|
document.getElementById("gmaps").href =
|
|
`https://www.google.com/maps?q=${lat},${lng}`;
|
|
|
|
document.getElementById("applemaps").href =
|
|
`https://maps.apple.com/?ll=${lat},${lng}`;
|
|
}
|
|
|
|
async function main() {
|
|
const config = await loadConfig();
|
|
|
|
const { name, lat, lng } = config;
|
|
|
|
document.getElementById("title").innerText = "Finde den Standort der Fotobox";
|
|
initMap(lat, lng);
|
|
setLinks(lat, lng);
|
|
}
|
|
|
|
main();
|