-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
190 lines (179 loc) · 7.75 KB
/
index.html
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<title>Adventsfenster</title>
<meta property="og:description" content="Adventsfenster mit MapLibre anzeigen" />
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel='stylesheet' href='https://unpkg.com/[email protected]/dist/maplibre-gl.css' />
<script src='https://unpkg.com/[email protected]/dist/maplibre-gl.js'></script>
<!-- add MapLibre JavaScript and CSS -->
<!-- <script src="https://tiles.versatiles.org/assets/maplibre-gl/maplibre-gl.js"></script>
<link href="https://tiles.versatiles.org/assets/maplibre-gl/maplibre-gl.css" rel="stylesheet" /> -->
<style>
html, body {
height: 100%;
margin: 0;
overflow: hidden;
}
#map {
height: 100%;
}
/* Legenden-Styling */
.map-legend {
position: absolute;
bottom: 20px;
left: 20px;
background-color: rgba(255, 255, 255, 0.8);
border: 1px solid #ccc;
border-radius: 8px;
padding: 10px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
font-family: Arial, sans-serif;
font-size: 14px;
color: #333;
}
.map-legend h4 {
margin: 0 0 8px 0;
font-size: 16px;
color: #8B0000;
}
.map-legend .legend-item {
display: flex;
align-items: center;
margin-bottom: 5px;
}
.map-legend .legend-item img {
width: 20px;
height: 20px;
margin-right: 8px;
}
</style>
</head>
<body>
<div id="map"></div>
<div class="map-legend">
<h4>Legende</h4>
<div class="legend-item">
<img src="./stern_gelb.png" alt="Gelber Stern">
<span>Adventsfenster (keine Einweihung)</span>
</div>
<div class="legend-item">
<img src="./stern_rot.png" alt="Roter Stern">
<span>Adventsfenster (mit Einweihung)</span>
</div>
</div>
<script>
const map = new maplibregl.Map({
container: 'map',
// style: 'https://tiles.versatiles.org/assets/styles/colorful.json',
// style: 'https://tiles.versatiles.org/assets/styles/neutrino.json',
// style: "https://vectortiles.geo.admin.ch/styles/ch.swisstopo.leichte-basiskarte.vt/style.json",
style: 'https://api.maptiler.com/maps/streets/style.json?key=ZSYofwXTrLbPGfAjpLHh',
center: [9.37, 47.568], // Zentrum der Karte (Romanshorn)
zoom: 14,
minZoom: 13,
maxZoom: 18
});
// Füge die Zoom-Steuerung hinzu
const nav = new maplibregl.NavigationControl({
showZoom: true, // Zoom-Buttons anzeigen
showCompass: false // Kompass nicht anzeigen (optional)
});
map.addControl(nav, 'top-right'); // Position der Zoom-Steuerung (oben rechts)
map.on('load', async () => {
// Lade Bilder für die Marker
const gelberStern = await map.loadImage('./stern_gelb.png');
const roterStern = await map.loadImage('./stern_rot.png');
// Füge die Markerbilder hinzu
map.addImage('stern_gelb', gelberStern.data);
map.addImage('stern_rot', roterStern.data);
// Füge die GeoJSON-Quelle für die Adventsfenster hinzu
map.addSource('adventsfenster', {
'type': 'geojson',
'data': './adventsfenster.geojson' // GeoJSON-Datei laden
});
// Layer für gelbe Sterne (Einweihung == null)
map.addLayer({
'id': 'adventsfenster-yellow',
'type': 'symbol',
'source': 'adventsfenster',
'filter': ['==', ['get', 'Einweihung'], null], // Filter: Einweihung ist null
'layout': {
'icon-image': 'stern_gelb', // Gelbes Sternbild verwenden
'icon-size': 0.4,
'icon-allow-overlap': true
}
});
// Layer für rote Sterne (Einweihung != null)
map.addLayer({
'id': 'adventsfenster-red',
'type': 'symbol',
'source': 'adventsfenster',
'filter': ['!=', ['get', 'Einweihung'], null], // Filter: Einweihung ist nicht null
'layout': {
'icon-image': 'stern_rot', // Rotes Sternbild verwenden
'icon-size': 0.4,
'icon-allow-overlap': true
}
});
// Layer für Text mit den Nummern der Adventsfenster
map.addLayer({
'id': 'adventsfenster-number',
'type': 'symbol',
'source': 'adventsfenster',
'layout': {
'text-field': ['get', 'Nummer'], // Nummer aus GeoJSON holen
// 'text-field': '1', // Nummer direkt in die Text einsetzen
'text-font': ['Frutiger', 'sans-serif'],
'text-size': 12,
'text-anchor': 'center',
'text-offset': [0, 0.2],
'text-allow-overlap': true
},
'paint': {
'text-halo-color': 'white', // Halo-Effekt für Text
'text-halo-width': 2, // Breite des Halo-Effekts
'text-halo-blur': 1 // Weicher Halo-Effekt
}
});
// Popup für die Markierungen hinzufügen
map.on('click', 'adventsfenster-number', function(e) {
var coordinates = e.features[0].geometry.coordinates.slice();
var properties = e.features[0].properties;
// Popup-Inhalt mit Weihnachtsdesign
var description = `
<div style="
border: 2px solid #8B0000;
background-color: #FFF8DC;
border-radius: 10px;
padding: 10px;
text-align: center;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
font-family: 'Georgia', serif;">
<h3 style="
color: #8B0000;
margin: 0 0 5px 0;
font-size: 18px;">🎄 ${properties.Name || 'Adventsfenster'} 🎄</h3>
<p style="margin: 0; color: #006400;">Adresse: <strong>${properties.Adresse || '-'}</strong></p>
<p style="margin: 5px 0; color: #8B0000;">Einweihung: <strong>${properties.Einweihung || 'Keine Einweihung'}</strong></p>
<p style="margin: 0; font-size: 12px; color: #8B4513;">✨ Frohe Adventszeit! ✨</p>
</div>
`;
new maplibregl.Popup()
.setLngLat(coordinates)
.setHTML(description)
.addTo(map);
});
// Cursor bei Hover ändern
map.on('mouseenter', 'adventsfenster-number', function() {
map.getCanvas().style.cursor = 'pointer';
});
map.on('mouseleave', 'adventsfenster-number', function() {
map.getCanvas().style.cursor = '';
});
});
</script>
</body>
</html>