Altes Köln

Widget:LeafletWasWarWo: Unterschied zwischen den Versionen

Aus Altes Köln
Wechseln zu:Navigation, Suche
Die Seite wurde neu angelegt: „<noinclude> Leaflet Karte Köln – Was war wo </noinclude> <div id="map-frame"> <div id="map" style="width:100%; height:80vh; border:3px solid black; border-radius:10px;"></div> </div> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" /> <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script> <script> (function() { var map = L.map('map').setView([50.95, 6.95], 12); L.tileLayer('https://tile.op…“
 
Keine Bearbeitungszusammenfassung
 
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
<noinclude>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"/>
Leaflet Karte Köln – Was war wo
<link rel="stylesheet" href="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.css"/>
</noinclude>


<div id="map-frame">
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
    <div id="map" style="width:100%; height:80vh; border:3px solid black; border-radius:10px;"></div>
<script src="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js"></script>
 
<style>
 
#map-frame-www{
border-radius:8px;
}
 
#map-www{
width:100%;
height:80vh;
border:3px solid black;
border-radius:10px;
}
 
.legend{
display:none;
line-height:18px;
color:#555;
background:rgba(255,255,255,0.85);
padding:10px;
border-radius:5px;
box-shadow:0 0 15px rgba(0,0,0,0.2);
}
 
.legend i{
width:18px;
height:18px;
float:left;
margin-right:8px;
opacity:0.7;
}
 
.leaflet-popup-close-button{
font-size:24px !important;
padding:6px !important;
}
 
.www-title{
text-align:center;
font-weight:bold;
font-size:20px;
}
 
.www-footer{
text-align:center;
margin-top:10px;
}
 
</style>
 
<p class="www-title">
Köln – Was War Wo
</p>
 
<div id="map-frame-www">
<div id="map-www"></div>
</div>
</div>


<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<div class="www-footer">
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<a href="https://hermsdoerfer.familyds.com/" target="_blank"
style="text-decoration:none;font-size:15px;color:red;">
<strong>© Dietmar Hermsdörfer</strong>
</a>
</div>


<script>
<script>
(function() {
(function(){
 
var map=L.map('map-www',{
preferCanvas:true,
tap:window.screen.width<600
}).setView([50.95,6.95],12);
 
var osm=L.tileLayer(
'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
{maxZoom:19,attribution:'© OpenStreetMap'}
).addTo(map);
 
var satellite=L.tileLayer(
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
{attribution:'Tiles © Esri'}
);
 
L.control.layers({
"Open Street Map":osm,
"Satellit":satellite
}).addTo(map);
 
L.Control.geocoder({
position:'topleft',
defaultMarkGeocode:true,
placeholder:"Suche ..."
}).addTo(map);
 
function isPointInPolygon(latlng,layer){
 
var coords=layer.getLatLngs();
 
if(layer.feature.geometry.type==="MultiPolygon"){
return coords.some(part=>isInside(latlng,part[0]));
}
 
return isInside(latlng,coords[0]);
}
 
function isInside(latlng,poly){
 
var x=latlng.lat;
var y=latlng.lng;
var inside=false;
 
for(var i=0,j=poly.length-1;i<poly.length;j=i++){
 
var xi=poly[i].lat;
var yi=poly[i].lng;
var xj=poly[j].lat;
var yj=poly[j].lng;
 
var intersect=((yi>y)!=(yj>y)) &&
(x<(xj-xi)*(y-yi)/(yj-yi)+xi);
 
if(intersect) inside=!inside;
 
}
 
return inside;
}
 
map.whenReady(function(){
 
fetch('/alteskoeln/WWW.geojson')
 
.then(response=>response.json())
 
.then(data=>{
 
var geojsonLayer=L.geoJSON(data,{
 
renderer:L.canvas(),
 
style:function(feature){
 
var colors={
'Verteidigen & Schützen':'blue',
'Arbeiten & Transportieren':'gray',
'Beten & Heilen':'purple',
'Ackern & Mahlen':'green',
'Leben & Lernen':'orange'
};
 
return{
color:colors[feature.properties.Gruppe] || "black",
weight:2,
fillOpacity:0.4
};
 
}
 
}).addTo(map);
 
map.on('click',function(e){
 
var clickedFeatures=[];
 
geojsonLayer.eachLayer(function(layer){
 
if(isPointInPolygon(e.latlng,layer)){
clickedFeatures.push(layer.feature.properties);
}
 
});
 
if(clickedFeatures.length>0){
 
var content="<div style='max-height:50vh;overflow-y:auto;min-width:200px;'>";
 
if(clickedFeatures.length>1){
 
content+="<div style='background:#eee;padding:8px;margin-bottom:12px;font-weight:bold;text-align:center;border-radius:6px;'>"+
clickedFeatures.length+
" historische Orte hier</div>";
 
}
 
clickedFeatures.forEach(function(props){
 
var name=props.Name || "Unbekannt";
var nutzung=props.Nutzung || "-";
var von=props.von || "?";
var bis=props.bis || "?";
var info=props.Info || "";
 
var bild=props.Bild ?
'<a href="'+props.Bild+'" target="_blank"><img src="'+props.Bild+'" loading="lazy" style="width:100%;max-height:180px;object-fit:cover;border-radius:6px;margin-top:6px;"></a>'
:'';
 
var link=props.Link ?
'<br><a href="'+props.Link+'" target="_blank" style="color:blue;">➔ Mehr Infos</a>'
:'';
 
content+=
"<div style='margin-bottom:18px;border-bottom:1px solid #ccc;padding-bottom:12px;'>"+
"<b>"+name+"</b><br>"+
"<small><i>"+nutzung+"</i></small><br>"+
"<b>Zeit:</b> "+von+" bis "+bis+"<br>"+
"<p style='font-size:1em;line-height:1.4;margin:8px 0;'>"+info+"</p>"+
bild+link+
"</div>";
 
});
 
content+="</div>";
 
L.popup({
maxWidth:window.innerWidth<600?300:400,
minWidth:window.innerWidth<600?220:250,
autoPanPadding:[20,20]
})
.setLatLng(e.latlng)
.setContent(content)
.openOn(map);
 
}
 
});
 
});
 
});
 
var legend=L.control({position:'bottomright'});
 
legend.onAdd=function(){
 
var div=L.DomUtil.create('div','legend');
 
var grades=[
{label:'Verteidigen & Schützen',color:'blue'},
{label:'Arbeiten & Transportieren',color:'gray'},
{label:'Beten & Heilen',color:'purple'},
{label:'Ackern & Mahlen',color:'green'},
{label:'Leben & Lernen',color:'orange'}
];
 
div.innerHTML+='<b>Kategorien</b><br>';
 
for(var i=0;i<grades.length;i++){
div.innerHTML+='<i style="background:'+grades[i].color+'"></i> '+grades[i].label+'<br>';
}
 
return div;
};
 
legend.addTo(map);
 
var toggleButton=L.control({position:'bottomright'});
 
toggleButton.onAdd=function(){
 
var btn=L.DomUtil.create('button','leaflet-bar');
 
btn.innerHTML='Legende';


    var map = L.map('map').setView([50.95, 6.95], 12);
btn.style.padding='5px 10px';
btn.style.cursor='pointer';
btn.style.backgroundColor='white';
btn.style.fontWeight='bold';
btn.style.border='2px solid rgba(0,0,0,0.2)';
btn.style.borderRadius='4px';


    L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
btn.onclick=function(e){
        maxZoom: 19,
        attribution: '&copy; OpenStreetMap'
    }).addTo(map);


    fetch('/alteskoeln/Was_War_Wo.geojson')  // ggf. Pfad anpassen!
L.DomEvent.stopPropagation(e);
      .then(response => response.json())
      .then(data => {
        L.geoJSON(data, {


            style: function (feature) {
var legendDiv=document.querySelector('.legend');
                switch (feature.properties.Nutzung) {
                    case 'Militär': return {color: "blue", weight: 1};
                    case 'Fabrik': return {color: "#ff0000", weight: 1};
                    case 'Bahn': return {color: "black", weight: 1};
                    case 'Freizeit': return {color: "green", weight: 1};
                    default: return {color: "#888888", weight: 1};
                }
            },


            onEachFeature: function (feature, layer) {
legendDiv.style.display=
(legendDiv.style.display==="none") ?
"block" : "none";


                for (let key in feature.properties) {
};
                    if (feature.properties[key] === null) {
                        feature.properties[key] = "";
                    }
                }


                var popupContent =
return btn;
                    "<b>Name:</b> " + feature.properties.Name + "<br>" +
                    "<b>Nutzung:</b> " + feature.properties.Nutzung + "<br>" +
                    "<b>von:</b> " + feature.properties.von + "<br>" +
                    "<b>bis:</b> " + feature.properties.bis + "<br>" +
                    "<b>Info:</b> " + feature.properties.Info + "<br>" +
                    '<a href="' + feature.properties.Bild + '" target="_blank"><img src="' + feature.properties.Bild + '" width="150px" /></a><br>' +
                    '<a href="' + feature.properties.Link + '" target="_blank">Mehr Infos</a>';


                layer.bindPopup(popupContent);
};
            }


        }).addTo(map);
toggleButton.addTo(map);
      });


})();
})();
</script>
</script>

Aktuelle Version vom 9. März 2026, 12:36 Uhr

<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"/> <link rel="stylesheet" href="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.css"/>

<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script> <script src="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js"></script>

<style>

  1. map-frame-www{

border-radius:8px; }

  1. map-www{

width:100%; height:80vh; border:3px solid black; border-radius:10px; }

.legend{ display:none; line-height:18px; color:#555; background:rgba(255,255,255,0.85); padding:10px; border-radius:5px; box-shadow:0 0 15px rgba(0,0,0,0.2); }

.legend i{ width:18px; height:18px; float:left; margin-right:8px; opacity:0.7; }

.leaflet-popup-close-button{ font-size:24px !important; padding:6px !important; }

.www-title{ text-align:center; font-weight:bold; font-size:20px; }

.www-footer{ text-align:center; margin-top:10px; }

</style>

Köln – Was War Wo

<script> (function(){

var map=L.map('map-www',{ preferCanvas:true, tap:window.screen.width<600 }).setView([50.95,6.95],12);

var osm=L.tileLayer( 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', {maxZoom:19,attribution:'© OpenStreetMap'} ).addTo(map);

var satellite=L.tileLayer( 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {attribution:'Tiles © Esri'} );

L.control.layers({ "Open Street Map":osm, "Satellit":satellite }).addTo(map);

L.Control.geocoder({ position:'topleft', defaultMarkGeocode:true, placeholder:"Suche ..." }).addTo(map);

function isPointInPolygon(latlng,layer){

var coords=layer.getLatLngs();

if(layer.feature.geometry.type==="MultiPolygon"){ return coords.some(part=>isInside(latlng,part[0])); }

return isInside(latlng,coords[0]); }

function isInside(latlng,poly){

var x=latlng.lat; var y=latlng.lng; var inside=false;

for(var i=0,j=poly.length-1;i<poly.length;j=i++){

var xi=poly[i].lat; var yi=poly[i].lng; var xj=poly[j].lat; var yj=poly[j].lng;

var intersect=((yi>y)!=(yj>y)) && (x<(xj-xi)*(y-yi)/(yj-yi)+xi);

if(intersect) inside=!inside;

}

return inside; }

map.whenReady(function(){

fetch('/alteskoeln/WWW.geojson')

.then(response=>response.json())

.then(data=>{

var geojsonLayer=L.geoJSON(data,{

renderer:L.canvas(),

style:function(feature){

var colors={ 'Verteidigen & Schützen':'blue', 'Arbeiten & Transportieren':'gray', 'Beten & Heilen':'purple', 'Ackern & Mahlen':'green', 'Leben & Lernen':'orange' };

return{ color:colors[feature.properties.Gruppe] || "black", weight:2, fillOpacity:0.4 };

}

}).addTo(map);

map.on('click',function(e){

var clickedFeatures=[];

geojsonLayer.eachLayer(function(layer){

if(isPointInPolygon(e.latlng,layer)){ clickedFeatures.push(layer.feature.properties); }

});

if(clickedFeatures.length>0){

var content="

";

if(clickedFeatures.length>1){

content+="
"+

clickedFeatures.length+

" historische Orte hier
";

}

clickedFeatures.forEach(function(props){

var name=props.Name || "Unbekannt"; var nutzung=props.Nutzung || "-"; var von=props.von || "?"; var bis=props.bis || "?"; var info=props.Info || "";

var bild=props.Bild ? '<a href="'+props.Bild+'" target="_blank"><img src="'+props.Bild+'" loading="lazy" style="width:100%;max-height:180px;object-fit:cover;border-radius:6px;margin-top:6px;"></a>'

;

var link=props.Link ? '
<a href="'+props.Link+'" target="_blank" style="color:blue;">➔ Mehr Infos</a>'

;

content+=

"
"+

""+name+"
"+ ""+nutzung+"
"+ "Zeit: "+von+" bis "+bis+"
"+

"

"+info+"

"+

bild+link+

"
";

});

content+="

";

L.popup({ maxWidth:window.innerWidth<600?300:400, minWidth:window.innerWidth<600?220:250, autoPanPadding:[20,20] }) .setLatLng(e.latlng) .setContent(content) .openOn(map);

}

});

});

});

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

legend.onAdd=function(){

var div=L.DomUtil.create('div','legend');

var grades=[ {label:'Verteidigen & Schützen',color:'blue'}, {label:'Arbeiten & Transportieren',color:'gray'}, {label:'Beten & Heilen',color:'purple'}, {label:'Ackern & Mahlen',color:'green'}, {label:'Leben & Lernen',color:'orange'} ];

div.innerHTML+='Kategorien
';

for(var i=0;i<grades.length;i++){ div.innerHTML+=' '+grades[i].label+'
'; }

return div; };

legend.addTo(map);

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

toggleButton.onAdd=function(){

var btn=L.DomUtil.create('button','leaflet-bar');

btn.innerHTML='Legende';

btn.style.padding='5px 10px'; btn.style.cursor='pointer'; btn.style.backgroundColor='white'; btn.style.fontWeight='bold'; btn.style.border='2px solid rgba(0,0,0,0.2)'; btn.style.borderRadius='4px';

btn.onclick=function(e){

L.DomEvent.stopPropagation(e);

var legendDiv=document.querySelector('.legend');

legendDiv.style.display= (legendDiv.style.display==="none") ? "block" : "none";

};

return btn;

};

toggleButton.addTo(map);

})(); </script>