-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
315 lines (258 loc) · 15.7 KB
/
index.html
File metadata and controls
315 lines (258 loc) · 15.7 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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>BPV Kaart HMC</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/>
<link rel="stylesheet" href="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.Default.css" />
<style>
body { padding: 0; margin: 0; font-family: sans-serif; }
html, body, #map { height: 100%; width: 100vw; }
/* Popup styling */
.popup-content { min-width: 230px; }
.popup-header { font-size: 15px; font-weight: bold; margin-bottom: 2px; color: #333; }
.popup-cap { font-size: 12px; font-weight: bold; color: #555; margin-bottom: 8px; display: block; }
.popup-level { display: inline-block; padding: 2px 6px; border-radius: 4px; color: white; font-size: 11px; margin-bottom: 8px; font-weight: bold; margin-right: 3px; text-shadow: 0px 0px 2px rgba(0,0,0,0.5); }
.popup-content p { margin: 0 0 10px 0; font-size: 13px; color: #666; line-height: 1.4; }
/* Knoppen styling */
.btn-action {
display: inline-block; margin-top: 5px; margin-right: 5px; padding: 6px 10px;
background-color: #4285F4; color: white; text-decoration: none;
border-radius: 4px; font-size: 12px; font-weight: bold;
}
.btn-streetview { background-color: #FFC107; color: #333; }
.website-link { display: block; margin-top: 10px; color: #0078A8; font-size: 12px; text-decoration: none; }
.website-link:hover { text-decoration: underline; }
/* Route input styling */
.route-box { margin-top: 10px; padding-top: 8px; border-top: 1px solid #eee; background: #f9f9f9; padding: 8px; border-radius: 4px; }
.route-input {
width: 120px; padding: 5px; border: 1px solid #ccc; border-radius: 3px; font-size: 12px;
}
.btn-go {
background-color: #4caf50; color: white; border: none; padding: 5px 10px;
border-radius: 3px; cursor: pointer; font-weight: bold; font-size: 12px;
}
/* Legenda Linksonder */
.legend {
background: white; padding: 10px; border-radius: 5px; box-shadow: 0 0 15px rgba(0,0,0,0.2);
font-size: 11px; line-height: 16px; color: #555;
max-height: 300px; overflow-y: auto;
}
.legend h4 { margin: 0 0 5px 0; font-size: 12px; border-bottom: 1px solid #ddd; padding-bottom: 3px; }
.legend i { width: 10px; height: 10px; float: left; margin-right: 8px; opacity: 0.8; border-radius: 50%; margin-top: 3px; }
/* --- MENU STYLING (Rechtsboven) --- */
.leaflet-control-layers-expanded {
min-width: 200px !important;
padding: 10px !important;
box-shadow: 0 3px 14px rgba(0,0,0,0.4) !important;
}
/* De tussenkopjes in het menu */
.menu-header {
margin-top: 12px;
margin-bottom: 4px;
font-weight: bold;
color: #333;
text-transform: uppercase;
font-size: 11px;
border-bottom: 2px solid #eee;
padding-bottom: 2px;
}
/* Eerste kopje heeft geen witruimte boven nodig */
.menu-header:first-of-type { margin-top: 0; }
/* Ruimte tussen de checkboxes */
.leaflet-control-layers label { margin-bottom: 4px; }
</style>
</head>
<body>
<div id="map"></div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.4.1/papaparse.min.js"></script>
<script src="https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js"></script>
<script src="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js"></script>
<script>
// --- DATA LINK (GID 1928204680) ---
const googleSheetCSV = "https://docs.google.com/spreadsheets/d/e/2PACX-1vTqbtXG3aiyEMFV--hYMBFojn3Qx2h5fP-aY3cjlMANjGTo1PVhnzR_e_1WTz7Saj2JJFxrtu2hvRx_/pub?gid=1928204680&single=true&output=csv";
// --- KAART SETUP ---
var osmLayer = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '© OpenStreetMap' });
var googleStreets = L.tileLayer('http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',{ maxZoom: 20, subdomains:['mt0','mt1','mt2','mt3'] });
var googleSat = L.tileLayer('http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}',{ maxZoom: 20, subdomains:['mt0','mt1','mt2','mt3'] });
// Kaart aanmaken
var map = L.map('map', {
center: [52.1326, 5.2913],
zoom: 8,
layers: [googleStreets]
});
// Zoekbalk toevoegen
L.Control.geocoder({
defaultMarkGeocode: false
})
.on('markgeocode', function(e) {
var bbox = e.geocode.bbox;
var poly = L.polygon([
bbox.getSouthEast(), bbox.getNorthEast(),
bbox.getNorthWest(), bbox.getSouthWest()
]);
map.fitBounds(poly.getBounds());
})
.addTo(map);
// --- CLUSTERS MAKEN (6 BAKJES) ---
// Hout & Meubel
var cl_HM_N2 = L.markerClusterGroup({ maxClusterRadius: 40 });
var cl_HM_N3 = L.markerClusterGroup({ maxClusterRadius: 40 });
var cl_HM_N4 = L.markerClusterGroup({ maxClusterRadius: 40 });
// Interieur & Advies
var cl_IA_N2 = L.markerClusterGroup({ maxClusterRadius: 40 });
var cl_IA_N3 = L.markerClusterGroup({ maxClusterRadius: 40 });
var cl_IA_N4 = L.markerClusterGroup({ maxClusterRadius: 40 });
// Standaard alles aanzetten
map.addLayer(cl_HM_N2); //map.addLayer(cl_HM_N3); map.addLayer(cl_HM_N4);
//map.addLayer(cl_IA_N2); map.addLayer(cl_IA_N3); map.addLayer(cl_IA_N4);
// --- LAYER CONTROL (MENU) ---
var baseMaps = { "Kaart": googleStreets, "Satelliet": googleSat };
// We gebruiken hier simpele namen. Het scriptje onderaan voegt de headers toe.
var flatOverlayMaps = {
"<span style='color:#4caf50'>●</span> HM Niveau 2": cl_HM_N2,
"<span style='color:#ff9800'>●</span> HM Niveau 3": cl_HM_N3,
"<span style='color:#9c27b0'>●</span> HM Niveau 4": cl_HM_N4,
"<span style='color:#4caf50'>●</span> IA Niveau 2": cl_IA_N2,
"<span style='color:#ff9800'>●</span> IA Niveau 3": cl_IA_N3,
"<span style='color:#9c27b0'>●</span> IA Niveau 4": cl_IA_N4
};
L.control.layers(baseMaps, flatOverlayMaps, {collapsed: true}).addTo(map);
// --- LEGENDA (Linksonder) ---
var legend = L.control({position: 'bottomleft'});
legend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'legend');
div.innerHTML += "<h4>Hout & Meubel</h4>";
div.innerHTML += '<i style="background: #9c27b0"></i> Niveau 4<br>';
div.innerHTML += '<i style="background: #ff9800"></i> Niveau 3<br>';
div.innerHTML += '<i style="background: #4caf50"></i> Niveau 2<br>';
div.innerHTML += "<h4 style='margin-top:8px'>Interieur & Advies</h4>";
div.innerHTML += '<i style="background: #e91e63"></i> Niveau 4<br>';
div.innerHTML += '<i style="background: #ff9800"></i> Niveau 3<br>';
div.innerHTML += '<i style="background: #4caf50"></i> Niveau 2<br>';
div.innerHTML += "<h4 style='margin-top:8px; color:#f44336'>Status</h4>";
div.innerHTML += '<i style="background: #f44336"></i> VOL / Vraag docent<br>';
return div;
};
legend.addTo(map);
// --- ROUTE FUNCTIE (OV DEFAULT) ---
window.startRoute = function(lat, lng, inputId) {
var inputVeld = document.getElementById(inputId);
var vertrekPunt = inputVeld.value;
var baseUrl = "https://www.google.com/maps/dir/?api=1";
var destination = `&destination=${lat},${lng}`;
var mode = "&travelmode=transit"; // OV
var finalUrl = vertrekPunt && vertrekPunt.trim() !== ""
? `${baseUrl}&origin=${encodeURIComponent(vertrekPunt)}${destination}${mode}`
: `${baseUrl}${destination}${mode}`;
window.open(finalUrl, '_blank');
};
// --- DATA LADEN ---
function laadPunten() {
Papa.parse(googleSheetCSV, {
download: true,
header: true,
skipEmptyLines: true,
complete: function(results) {
var data = results.data;
console.log("Rijen geladen:", data.length);
data.forEach(function(rij) {
if(rij['LAT LONG'] && rij['LAT LONG'].includes(',')) {
var parts = rij['LAT LONG'].split(',');
var lat = parseFloat(parts[0]);
var lng = parseFloat(parts[1]);
var uniekId = rij.Id ? rij.Id : Math.floor(Math.random() * 1000000);
if (!isNaN(lat) && !isNaN(lng)) {
// DATA UITLEZEN
var status = rij.STATUS ? rij.STATUS.toLowerCase().trim() : '';
var capaciteit = rij.Capaciteit ? rij.Capaciteit : '?';
// Linkjes
var streetViewLink = `https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=${lat},${lng}`;
var url = rij.Website ? rij.Website.trim() : '';
if (url.length > 0 && !url.toLowerCase().startsWith('http')) url = 'http://' + url;
var websiteLink = url ? `<a href="${url}" target="_blank" class="website-link">🌐 Website bezoeken</a>` : '';
// MARKER FABRIEK
function maakMarker(kleur, niveauLabel, layerGroup) {
var finalColor = kleur;
var label = niveauLabel;
// Status check: Als V, dan rood
if (status === 'v') {
finalColor = '#f44336';
label = "VOL / Vraag docent";
}
var marker = L.circleMarker([lat, lng], {
radius: 8,
fillColor: finalColor,
color: "white", weight: 2, opacity: 1, fillOpacity: 0.9
});
var popupHTML = `
<div class="popup-content">
<div class="popup-header">${rij.Naam}</div>
<span class="popup-cap">Capaciteit: ${capaciteit}</span>
<span class="popup-level" style="background:${finalColor}">${label}</span>
<p>${rij.Adres}<br>${rij.Postcode} ${rij.Plaatsnaam}</p>
<a href="${streetViewLink}" target="_blank" class="btn-action btn-streetview">👀 Streetview</a>
${websiteLink}
<div class="route-box">
<small>Plan OV-route vanaf:</small><br>
<input type="text" id="route-${uniekId}-${label.replace(/\s/g,'')}" class="route-input" placeholder="Postcode of station...">
<button onclick="startRoute('${lat}', '${lng}', 'route-${uniekId}-${label.replace(/\s/g,'')}')" class="btn-go">Go</button>
</div>
</div>
`;
marker.bindPopup(popupHTML);
layerGroup.addLayer(marker);
}
// CHECK & PLAATS MARKERS (HM)
if (rij['HM_N2']) maakMarker('#4caf50', 'HM Niveau 2', cl_HM_N2);
if (rij['HM_N3']) maakMarker('#ff9800', 'HM Niveau 3', cl_HM_N3);
if (rij['HM_N4']) maakMarker('#9c27b0', 'HM Niveau 4', cl_HM_N4);
// CHECK & PLAATS MARKERS (IA)
if (rij['IA_N2']) maakMarker('#4caf50', 'IA Niveau 2', cl_IA_N2);
if (rij['IA_N3']) maakMarker('#ff9800', 'IA Niveau 3', cl_IA_N3);
if (rij['IA_N4']) maakMarker('#9c27b0', 'IA Niveau 4', cl_IA_N4);
}
}
});
}
});
}
laadPunten();
// --- MENU OPMAAK FIX (De "Buurman-Check") ---
setTimeout(function() {
// We selecteren direct de <label> elementen (de regels in het menu)
var labels = document.querySelectorAll('.leaflet-control-layers-overlays label');
labels.forEach(function(label) {
// Pak de tekst in het label
var span = label.querySelector('span');
if (!span) return; // Veiligheidscheck
var tekst = span.innerHTML;
// DE BUURMAN CHECK: Kijk naar het element direct hierboven
var buurman = label.previousElementSibling;
// Als de buurman bestaat én het is al onze header... STOP DAN!
if (buurman && buurman.classList.contains('menu-header')) {
return;
}
// 1. Zoek Hout & Meubel
if (tekst.includes('HM Niveau 2')) {
var header = document.createElement('div');
header.className = 'menu-header';
header.innerHTML = '📂 Hout & Meubel';
label.parentElement.insertBefore(header, label);
}
// 2. Zoek Interieur & Advies
if (tekst.includes('IA Niveau 2')) {
var header = document.createElement('div');
header.className = 'menu-header';
header.innerHTML = '📂 Interieur & Advies';
label.parentElement.insertBefore(header, label);
}
});
}, 500); // Wacht een halve seconde (veiliger)
</script>
</body>
</html>