2020-11-09 23:54:21 +01:00
|
|
|
const aufgabe2 = () => {
|
2020-11-26 02:18:35 +01:00
|
|
|
|
|
|
|
const createIcon = imgName => L.icon({
|
|
|
|
iconUrl: `markers/${imgName}.png`,
|
|
|
|
iconSize: [60, 60],
|
|
|
|
iconAnchor: [30, 60],
|
|
|
|
popupAnchor: [0, -53]
|
|
|
|
})
|
|
|
|
|
2020-11-09 23:54:21 +01:00
|
|
|
const markerIcons = {
|
2020-11-26 02:18:35 +01:00
|
|
|
food: createIcon("food"),
|
|
|
|
culture: createIcon("culture"),
|
|
|
|
nature: createIcon("landscape"),
|
|
|
|
train: createIcon("train")
|
2020-11-09 23:54:21 +01:00
|
|
|
}
|
|
|
|
|
2020-11-21 19:33:24 +01:00
|
|
|
let map = L.map('poiMap').setView([48.779694, 9.177015], 14);
|
2020-11-09 23:54:21 +01:00
|
|
|
map.addLayer(new L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
|
|
attribution: 'Map data <a href="https://openstreetmap.org">OpenStreetMap</a> contributors',
|
2020-11-26 02:18:35 +01:00
|
|
|
minZoom: 0,
|
|
|
|
maxZoom: 19
|
2020-11-09 23:54:21 +01:00
|
|
|
}))
|
|
|
|
|
2020-11-26 02:18:35 +01:00
|
|
|
const createFoodMarker = (coords, text) => L.marker(coords, {icon: markerIcons.food}).bindPopup(`<b>Essen und Trinken</b><br>${text}`)
|
|
|
|
const createCultureMarker = (coords, text) => L.marker(coords, {icon: markerIcons.culture}).bindPopup(`<b>Kunst und Kultur</b><br>${text}`)
|
|
|
|
const createNatureMarker = (coords, text) => L.marker(coords, {icon: markerIcons.nature}).bindPopup(`<b>Natur</b><br>${text}`)
|
|
|
|
const createTrainMarker = (coords, text) => L.marker(coords, {icon: markerIcons.train}).bindPopup(`<b>ÖPNV</b><br>${text}`)
|
|
|
|
|
2020-11-09 23:54:21 +01:00
|
|
|
const foodLayer = L.layerGroup([
|
2020-11-26 02:18:35 +01:00
|
|
|
createFoodMarker([48.780980, 9.169636], "Mensa Stuttgart"),
|
|
|
|
createFoodMarker([48.778051, 9.176946], "Ochs'n Willi"),
|
|
|
|
createFoodMarker([48.779674, 9.178160], "Königsbau Passagen"),
|
|
|
|
createFoodMarker([48.780378, 9.172597], "HFT Block 4")
|
2020-11-09 23:54:21 +01:00
|
|
|
])
|
|
|
|
|
|
|
|
const cultureLayer = L.layerGroup([
|
2020-11-26 02:18:35 +01:00
|
|
|
createCultureMarker([48.788165, 9.233864], "Mercedes-Benz Museum"),
|
|
|
|
createCultureMarker([48.793296, 9.228010], "Porsche Arena"),
|
|
|
|
createCultureMarker([48.834270, 9.152479], "Porsche Museum"),
|
|
|
|
createCultureMarker([48.755866, 9.190109], "Fernsehturm"),
|
|
|
|
createCultureMarker([48.780149, 9.186586], "Staatsgalerie"),
|
|
|
|
createCultureMarker([48.786550, 9.084028], "Schloss Solitude")
|
2020-11-09 23:54:21 +01:00
|
|
|
])
|
|
|
|
|
|
|
|
const natureLayer = L.layerGroup([
|
2020-11-26 02:18:35 +01:00
|
|
|
createNatureMarker([48.804148, 9.208100], "Wilhelma"),
|
|
|
|
createNatureMarker([48.782037, 9.268643], "Grabkapelle auf dem Württemberg"),
|
|
|
|
createNatureMarker([48.785969, 9.187023], "Schlossgarten"),
|
|
|
|
createNatureMarker([48.818362, 9.184177], "Aussichtspunkt Burgholzhof")
|
2020-11-09 23:54:21 +01:00
|
|
|
])
|
|
|
|
|
|
|
|
const trainLayer = L.layerGroup([
|
2020-11-26 02:18:35 +01:00
|
|
|
createTrainMarker([48.777440, 9.173764], "Rotebühlplatz"),
|
|
|
|
createTrainMarker([48.784760, 9.182898], "Stuttgart Hauptbahnhof"),
|
|
|
|
createTrainMarker([48.780173, 9.177220], "Börsenplatz"),
|
|
|
|
createTrainMarker([48.755939, 9.142164], "Seilbahn"),
|
|
|
|
createTrainMarker([48.764290, 9.168611], "Zahnradbahn"),
|
2020-11-09 23:54:21 +01:00
|
|
|
])
|
|
|
|
|
|
|
|
const overlayMaps = {
|
|
|
|
'Essen und Trinken': foodLayer,
|
|
|
|
'Kunst und Kultur': cultureLayer,
|
|
|
|
'Natur': natureLayer,
|
|
|
|
'ÖPNV': trainLayer
|
|
|
|
}
|
|
|
|
|
2020-11-26 02:18:35 +01:00
|
|
|
Object.values(overlayMaps).forEach(layer => map.addLayer(layer))
|
2020-11-09 23:54:21 +01:00
|
|
|
L.control.layers(null, overlayMaps).addTo(map)
|
|
|
|
}
|
|
|
|
|
|
|
|
aufgabe2()
|