-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathleaflet.html
More file actions
73 lines (66 loc) · 2.65 KB
/
leaflet.html
File metadata and controls
73 lines (66 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Leaflet Karte mit GeoJSON</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<style>
#map {
width: 100%;
height: 100vh;
}
.popup-content img {
max-width: 100%;
height: auto;
border-radius: 5px;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
// Karte initialisieren
const map = L.map('map').setView([0.0, 0.0], 2);
// OpenStreetMap Layer hinzufügen
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© OpenStreetMap'
}).addTo(map);
// GeoJSON-Daten laden
fetch('geojson_results.json')
.then(response => response.json())
.then(data => {
// GeoJSON-Daten zur Karte hinzufügen
L.geoJSON(data, {
onEachFeature: function (feature, layer) {
// Popup-Inhalt erstellen
const properties = feature.properties;
const popupContent = `
<div class="popup-content">
<strong>${properties.name || 'Unbekannt'}</strong><br>
<img src="${properties.thumbnail}" alt="${properties.name}" /><br>
Lizenz: <a href="${properties.license}" target="_blank">${properties.license || 'Keine Lizenz'}</a><br>
Ersteller: ${properties.creator || 'Unbekannt'}<br>
Webseite: <a href="${properties.url}" target="_blank">${properties.url || 'Keine Webseite'}</a>
</div>
`;
layer.bindPopup(popupContent);
},
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, {
radius: 8,
fillColor: '#FF0000',
color: '#000000',
weight: 1,
opacity: 1,
fillOpacity: 0.8
});
}
}).addTo(map);
})
.catch(error => console.error('Fehler beim Laden des GeoJSON:', error));
</script>
</body>
</html>