Altes Köln

Widget:Schulkarte

Aus Altes Köln
Wechseln zu:Navigation, Suche

Dies ist ein Widget für die Schulkarte.


<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" /> <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script> <script src="https://unpkg.com/leaflet.markercluster/dist/leaflet.markercluster.js"></script> <link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster/dist/MarkerCluster.css" /> <link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster/dist/MarkerCluster.Default.css" />

<script>

// === ICONSETS =======================================

var iconGrund = new L.Icon({

   iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-green.png',
   iconSize: [25, 41], iconAnchor: [12, 41], popupAnchor: [1, -34]

});

var iconGym = new L.Icon({

   iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-blue.png',
   iconSize: [25, 41], iconAnchor: [12, 41], popupAnchor: [1, -34]

});

var iconGes = new L.Icon({

   iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-orange.png',
   iconSize: [25, 41], iconAnchor: [12, 41], popupAnchor: [1, -34]

});

var iconBeruf = new L.Icon({

   iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-violet.png',
   iconSize: [25, 41], iconAnchor: [12, 41], popupAnchor: [1, -34]

});

var iconFoerder = new L.Icon({

   iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png',
   iconSize: [25, 41], iconAnchor: [12, 41], popupAnchor: [1, -34]

});

// === CLUSTER COLORS =================================

function clusterColor(color){

   return new L.MarkerClusterGroup({
       iconCreateFunction: function(cluster) {
           return new L.DivIcon({

html: '

' + cluster.getChildCount() + '

'

           });
       }
   });

}

var clusterGrund = clusterColor('#32CD32'); var clusterGym = clusterColor('#1E90FF'); var clusterGes = clusterColor('#FF8C00'); var clusterBeruf = clusterColor('#9400D3'); var clusterFoerder = clusterColor('#DC143C');

// === MAP ============================================

var map = L.map('map').setView([50.94, 6.96], 11);

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {

   maxZoom: 18

}).addTo(map);

// === SMW COORD PARSER ===============================

function extractCoords(coordValue) {

   if (!coordValue) return null;
   if (typeof coordValue === "string") {
       let parts = coordValue.split(',');
       if (parts.length === 2) {
           return [parseFloat(parts[0]), parseFloat(parts[1])];
       }
   }
   if (typeof coordValue === "object" && coordValue.lat && coordValue.lon) {
       return [parseFloat(coordValue.lat), parseFloat(coordValue.lon)];
   }
   return null;

}

// === Marker Import via SMW ==========================

// Wird durch SMW ersetzt:

 KoordinatenSchultyplink
Albertus-Magnus-Gymnasium50.957844, 6.927127Gymnasium
An der Rechtschule/Haus-Nr. 3
Apostelgymnasium50.932315, 6.916149Gymnasium
Bildung in Köln
Deutzer Gymnasium Schaurtestraße50.933561, 6.97612Gymnasium
Dreikönigsgymnasium50.967042, 6.928844Gymnasium
Erzbischöfliche Ursulinenschule
Friedrich-Wilhelm-Gymnasium50.930772, 6.95645Gymnasium
Genoveva-Gymnasium
Gymnasium Kreuzgasse
Gymnasium Laurentianum
Gymnasium MontanumGymnasium
Hansagymnasium50.947983, 6.950817Gymnasium
Hier gibt's noch was zu tun
Hosengasse/Haus-Nr. 10
Humboldt-Gymnasium50.926468, 6.948525Gymnasium
Höhere Bürgerschule
Kaiser-Wilhelm-GymnasiumGymnasium
Kaiserin-Augusta-Schule50.93166, 6.958228Gymnasium
Kaiserin-Theophanu-Schule
Königin-Luise-Schule50.939167, 6.943333Gymnasium
Schiller-Gymnasium50.923241, 6.930154Gymnasium
Schulen in Köln
Schulen in Köln/Bezirk 1
Schulen in Köln/Bezirk 2
Schulen in Köln/Bezirk 3
Schulen in Köln/Bezirk 4
Schulen in Köln/Bezirk 5
Schulen in Köln/Bezirk 6
Schulen in Köln/Bezirk 7
Schulen in Köln/Bezirk 8

var bounds = [];

schoolData.forEach(function(school){

   var coords = extractCoords(school.Koordinaten);
   if(!coords) return;
   // choose icon
   var icon = iconGrund;
   switch(school.Schultyp){
       case "Grundschule": icon = iconGrund; break;
       case "Gymnasium": icon = iconGym; break;
       case "Gesamtschule": icon = iconGes; break;
       case "Berufskolleg": icon = iconBeruf; break;
       case "Förderschule": icon = iconFoerder; break;
   }
   var marker = L.marker(coords, {icon: icon})
       .bindPopup('' + school.link + '
' + school.Schultyp);
   switch(school.Schultyp){
       case "Grundschule": clusterGrund.addLayer(marker); break;
       case "Gymnasium": clusterGym.addLayer(marker); break;
       case "Gesamtschule": clusterGes.addLayer(marker); break;
       case "Berufskolleg": clusterBeruf.addLayer(marker); break;
       case "Förderschule": clusterFoerder.addLayer(marker); break;
       default: clusterGrund.addLayer(marker);
   }
   bounds.push(coords);

});

// Standard sichtbar: clusterGrund.addTo(map); clusterGym.addTo(map);

// Layer Control L.control.layers(null, {

   "Grundschulen": clusterGrund,
   "Gymnasien": clusterGym,
   "Gesamtschulen": clusterGes,
   "Berufskollegs": clusterBeruf,
   "Förderschulen": clusterFoerder

}, {collapsed:false}).addTo(map);

// === AUTO FIT ======================================= if(bounds.length > 0){

   map.fitBounds(bounds);

}

// === LEGENDE ========================================

var legend = L.control({ position: 'bottomright' });

legend.onAdd = function () {

   var div = L.DomUtil.create('div', 'info legend');
   div.style.background = 'white';
   div.style.padding = '10px';
   div.style.borderRadius = '6px';
   div.style.boxShadow = '0 0 6px rgba(0,0,0,0.3)';
   div.style.fontSize = "13px";
   div.innerHTML += "Schultypen
"; div.innerHTML += "<img src='https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-green.png' width='18'> Grundschule
"; div.innerHTML += "<img src='https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-blue.png' width='18'> Gymnasium
"; div.innerHTML += "<img src='https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-orange.png' width='18'> Gesamtschule
"; div.innerHTML += "<img src='https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-violet.png' width='18'> Berufskolleg
"; div.innerHTML += "<img src='https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png' width='18'> Förderschule
";
   return div;

}; legend.addTo(map);

</script>

Cookies helfen uns bei der Bereitstellung von Altes Köln. Durch die Nutzung von Altes Köln erklärst du dich damit einverstanden, dass wir Cookies speichern.