1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-02 19:55:18 +02:00

Merge pull request #140 from seanmorley15/development

Development
This commit is contained in:
Sean Morley 2024-07-24 11:02:17 -04:00 committed by GitHub
commit f6aa5f089f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 34334 additions and 4 deletions

View file

@ -127,7 +127,7 @@ STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
# TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
import type { Adventure } from '$lib/types';
import type { Adventure, VisitedRegion } from '$lib/types';
const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
export const load = (async (event) => {
@ -13,6 +13,26 @@ export const load = (async (event) => {
Cookie: `${event.cookies.get('auth')}`
}
});
let visitedRegionsFetch = await fetch(`${endpoint}/api/visitedregion/`, {
headers: {
Cookie: `${event.cookies.get('auth')}`
}
});
let visitedRegions = (await visitedRegionsFetch.json()) as VisitedRegion[];
let USfetch = await fetch(`${endpoint}/static/data/us.json`);
let USjson = await USfetch.json();
if (!USjson) {
console.error('Failed to fetch US GeoJSON');
}
let CAfetch = await fetch(`${endpoint}/static/data/ca.json`);
let CAjson = await CAfetch.json();
if (!CAjson) {
console.error('Failed to fetch CA GeoJSON');
}
if (!visitedFetch.ok) {
console.error('Failed to fetch visited adventures');
return redirect(302, '/login');
@ -29,9 +49,13 @@ export const load = (async (event) => {
type: adventure.type
};
});
return {
props: {
markers
markers,
USjson,
CAjson,
visitedRegions
}
};
}

View file

@ -1,15 +1,48 @@
<script>
// @ts-nocheck
import { DefaultMarker, MapEvents, MapLibre, Popup, Marker } from 'svelte-maplibre';
import {
DefaultMarker,
MapEvents,
MapLibre,
Popup,
Marker,
GeoJSON,
LineLayer,
FillLayer,
SymbolLayer
} from 'svelte-maplibre';
export let data;
let clickedName = '';
let markers = data.props.markers;
let us = data.props.USjson;
let ca = data.props.CAjson;
// combine the two geojsons
let geoJSON = {
type: 'FeatureCollection',
features: [...us.features, ...ca.features]
};
console.log(markers);
let visitedRegions = data.props.visitedRegions;
let visitArray = [];
// turns in into an array of the visits
visitedRegions.forEach((el) => {
visitArray.push(el.region);
});
let showGEO = true;
</script>
<label for="show-geo">Show Borders?</label>
<input type="checkbox" id="shpw-gep" name="show-geo" class="checkbox" bind:checked={showGEO} />
<MapLibre
style="https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
class="relative aspect-[9/16] max-h-[70vh] w-full sm:aspect-video sm:max-h-full"
@ -60,6 +93,29 @@
</Marker>
{/if}
{/each}
{#if showGEO}
<GeoJSON id="states" data={geoJSON} promoteId="ISOCODE">
<LineLayer
layout={{ 'line-cap': 'round', 'line-join': 'round' }}
paint={{ 'line-color': 'grey', 'line-width': 3 }}
beforeLayerType="symbol"
/>
<FillLayer
paint={{ 'fill-color': 'rgba(37, 244, 26, 0.15)' }}
filter={['in', 'ISOCODE', ...visitArray]}
/>
<!-- <SymbolLayer
layout={{
'text-field': ['slice', ['get', 'ISOCODE'], 3],
'text-size': 12,
'text-anchor': 'center'
}}
paint={{
'text-color': 'black'
}}
/> -->
</GeoJSON>
{/if}
</MapLibre>
<style>