mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-28 17:29:36 +02:00
France
This commit is contained in:
parent
0720481937
commit
0887579129
3 changed files with 14605 additions and 13 deletions
14588
backend/server/static/data/fr.json
Normal file
14588
backend/server/static/data/fr.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -5,7 +5,7 @@ import type { Adventure, VisitedRegion } from '$lib/types';
|
||||||
const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
|
const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
|
||||||
|
|
||||||
export const load = (async (event) => {
|
export const load = (async (event) => {
|
||||||
let countryCodesToFetch = ['US', 'CA'];
|
let countryCodesToFetch = ['FR', 'US', 'CA'];
|
||||||
let geoJSON = {
|
let geoJSON = {
|
||||||
type: 'FeatureCollection',
|
type: 'FeatureCollection',
|
||||||
features: []
|
features: []
|
||||||
|
@ -27,22 +27,24 @@ export const load = (async (event) => {
|
||||||
});
|
});
|
||||||
let visitedRegions = (await visitedRegionsFetch.json()) as VisitedRegion[];
|
let visitedRegions = (await visitedRegionsFetch.json()) as VisitedRegion[];
|
||||||
|
|
||||||
countryCodesToFetch.forEach(async (code) => {
|
await Promise.all(
|
||||||
let res = await fetch(`${endpoint}/static/data/${code.toLowerCase()}.json`);
|
countryCodesToFetch.map(async (code) => {
|
||||||
let json = await res.json();
|
let res = await fetch(`${endpoint}/static/data/${code.toLowerCase()}.json`);
|
||||||
if (!json) {
|
console.log('fetching ' + code);
|
||||||
console.error(`Failed to fetch ${code} GeoJSON`);
|
let json = await res.json();
|
||||||
} else {
|
if (!json) {
|
||||||
geoJSON.features = geoJSON.features.concat(json.features);
|
console.error(`Failed to fetch ${code} GeoJSON`);
|
||||||
}
|
} else {
|
||||||
});
|
geoJSON.features = geoJSON.features.concat(json.features);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
if (!visitedFetch.ok) {
|
if (!visitedFetch.ok) {
|
||||||
console.error('Failed to fetch visited adventures');
|
console.error('Failed to fetch visited adventures');
|
||||||
return redirect(302, '/login');
|
return redirect(302, '/login');
|
||||||
} else {
|
} else {
|
||||||
let visited = (await visitedFetch.json()) as Adventure[];
|
let visited = (await visitedFetch.json()) as Adventure[];
|
||||||
console.log('VISITEDL ' + visited);
|
|
||||||
// make a long lat array like this { lngLat: [-20, 0], name: 'Adventure 1' },
|
// make a long lat array like this { lngLat: [-20, 0], name: 'Adventure 1' },
|
||||||
let markers = visited
|
let markers = visited
|
||||||
.filter((adventure) => adventure.latitude !== null && adventure.longitude !== null)
|
.filter((adventure) => adventure.latitude !== null && adventure.longitude !== null)
|
||||||
|
@ -54,6 +56,8 @@ export const load = (async (event) => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('sent');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
markers,
|
markers,
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
paint={{ 'fill-color': 'rgba(37, 244, 26, 0.15)' }}
|
paint={{ 'fill-color': 'rgba(37, 244, 26, 0.15)' }}
|
||||||
filter={['in', 'ISOCODE', ...visitArray]}
|
filter={['in', 'ISOCODE', ...visitArray]}
|
||||||
/>
|
/>
|
||||||
<!-- <SymbolLayer
|
<SymbolLayer
|
||||||
layout={{
|
layout={{
|
||||||
'text-field': ['slice', ['get', 'ISOCODE'], 3],
|
'text-field': ['slice', ['get', 'ISOCODE'], 3],
|
||||||
'text-size': 12,
|
'text-size': 12,
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
paint={{
|
paint={{
|
||||||
'text-color': 'black'
|
'text-color': 'black'
|
||||||
}}
|
}}
|
||||||
/> -->
|
/>
|
||||||
</GeoJSON>
|
</GeoJSON>
|
||||||
{/if}
|
{/if}
|
||||||
</MapLibre>
|
</MapLibre>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue