diff --git a/src/pages/karte.astro b/src/pages/karte.astro index 5380663..9c7d066 100644 --- a/src/pages/karte.astro +++ b/src/pages/karte.astro @@ -187,9 +187,12 @@ const jsonld={'@context':'https://schema.org','@type':'WebApplication',name:'Kü const map=new maplibregl.Map({container:'map',style:'https://tiles.openfreemap.org/styles/liberty',center:[9.6,50.6],zoom:4.4}); map.addControl(new maplibregl.NavigationControl(),'top-right'); function setMap(list){ + // Karte erst befüllen, wenn der Style geladen ist (sonst getSource()=undefined -> würde render() abbrechen) + const sAll=map.getSource('all'), sAv=map.getSource('av'); + if(!sAll||!sAv)return; const all={type:'FeatureCollection',features:list.map(s=>({type:'Feature',geometry:{type:'Point',coordinates:[s.lo,s.la]},properties:{}}))}; const av={type:'FeatureCollection',features:list.filter(s=>status(s)?.a).map(s=>({type:'Feature',geometry:{type:'Point',coordinates:[s.lo,s.la]},properties:{n:s.n,ci:s.ci,t:s.t||null}}))}; - map.getSource('all').setData(all);map.getSource('av').setData(av); + sAll.setData(all);sAv.setData(av); } function priceStrip(){ const el=$('#pricestrip');