document.addEventListener('DOMContentLoaded', async () => {
    const map = L.map('map').setView([27.49, -9.3], 3);

    map.crs = L.CRS.EPSG4326;

    const world = await fetch('/world.geojson').then(res => res.json());
    const fieldwork = await fetch('/fieldwork.geojson').then(res => res.json());

    L.geoJson(world,{
        style: function () {
            return {
                color: '#fff',
                opacity: 0.4,
                weight: 2,
                fillColor: '#19365e',
                fillOpacity: 1
            };
        }
    }).addTo(map);

    L.geoJson(fieldwork,{
        style: function () {
            return {
                opacity: 0,
                fillColor: '#ce1417',
                fillOpacity: 1
            };
        }
    }).addTo(map);
    
    //TEST Egitto
    let egypt1 = L.marker([30.551944, 32.098611], {
            title: 'Tell el-Maskhuta',
            riseOnHover : true
        }).addTo(map);

    let egypt2 = L.marker([30.5494,31.9636], {
            title: 'Wadi Tumilat',
            riseOnHover : true
    }).addTo(map);

})
