1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-25 07:49:37 +02:00
This commit is contained in:
Sean Morley 2024-07-24 14:16:25 -04:00
parent 0720481937
commit 0887579129
3 changed files with 14605 additions and 13 deletions

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@ import type { Adventure, VisitedRegion } from '$lib/types';
const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
export const load = (async (event) => {
let countryCodesToFetch = ['US', 'CA'];
let countryCodesToFetch = ['FR', 'US', 'CA'];
let geoJSON = {
type: 'FeatureCollection',
features: []
@ -27,22 +27,24 @@ export const load = (async (event) => {
});
let visitedRegions = (await visitedRegionsFetch.json()) as VisitedRegion[];
countryCodesToFetch.forEach(async (code) => {
let res = await fetch(`${endpoint}/static/data/${code.toLowerCase()}.json`);
let json = await res.json();
if (!json) {
console.error(`Failed to fetch ${code} GeoJSON`);
} else {
geoJSON.features = geoJSON.features.concat(json.features);
}
});
await Promise.all(
countryCodesToFetch.map(async (code) => {
let res = await fetch(`${endpoint}/static/data/${code.toLowerCase()}.json`);
console.log('fetching ' + code);
let json = await res.json();
if (!json) {
console.error(`Failed to fetch ${code} GeoJSON`);
} else {
geoJSON.features = geoJSON.features.concat(json.features);
}
})
);
if (!visitedFetch.ok) {
console.error('Failed to fetch visited adventures');
return redirect(302, '/login');
} else {
let visited = (await visitedFetch.json()) as Adventure[];
console.log('VISITEDL ' + visited);
// make a long lat array like this { lngLat: [-20, 0], name: 'Adventure 1' },
let markers = visited
.filter((adventure) => adventure.latitude !== null && adventure.longitude !== null)
@ -54,6 +56,8 @@ export const load = (async (event) => {
};
});
console.log('sent');
return {
props: {
markers,

View file

@ -97,7 +97,7 @@
paint={{ 'fill-color': 'rgba(37, 244, 26, 0.15)' }}
filter={['in', 'ISOCODE', ...visitArray]}
/>
<!-- <SymbolLayer
<SymbolLayer
layout={{
'text-field': ['slice', ['get', 'ISOCODE'], 3],
'text-size': 12,
@ -106,7 +106,7 @@
paint={{
'text-color': 'black'
}}
/> -->
/>
</GeoJSON>
{/if}
</MapLibre>