1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-23 06:49:37 +02:00

Remove AUTHORS and MANIFEST.in files; add ReverseGeocodeViewSet and localization updates

This commit is contained in:
Sean Morley 2024-10-30 15:11:00 -04:00
parent 05076a6732
commit 83d06fc0a4
13 changed files with 109 additions and 42 deletions

View file

@ -1,6 +1,12 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import type { Adventure, Collection, OpenStreetMapPlace, Point } from '$lib/types';
import type {
Adventure,
Collection,
OpenStreetMapPlace,
Point,
ReverseGeocode
} from '$lib/types';
import { onMount } from 'svelte';
import { enhance } from '$app/forms';
import { addToast } from '$lib/toasts';
@ -27,6 +33,8 @@
let noPlaces: boolean = false;
let reverseGeocodePlace: ReverseGeocode | null = null;
let adventure: Adventure = {
id: '',
name: '',
@ -136,6 +144,12 @@
}
}
$: {
if (adventure.longitude && adventure.latitude) {
reverseGeocode();
}
}
async function fetchImage() {
let res = await fetch(url);
let data = await res.blob();
@ -249,29 +263,15 @@
async function reverseGeocode() {
let res = await fetch(
`https://nominatim.openstreetmap.org/search?q=${adventure.latitude},${adventure.longitude}&format=jsonv2`,
{
headers: {
'User-Agent': `AdventureLog / ${appVersion} `
}
}
`/api/reverse-geocode/reverse_geocode/?lat=${adventure.latitude}&lon=${adventure.longitude}`
);
let data = (await res.json()) as OpenStreetMapPlace[];
if (data.length > 0) {
adventure.name = data[0]?.name || '';
adventure.activity_types?.push(data[0]?.type || '');
adventure.location = data[0]?.display_name || '';
if (longitude && latitude) {
markers = [
{
lngLat: { lng: longitude, lat: latitude },
location: data[0]?.display_name || '',
name: data[0]?.name || '',
activity_type: data[0]?.type || ''
}
];
}
let data = await res.json();
if (data.error) {
console.log(data.error);
reverseGeocodePlace = null;
return;
}
reverseGeocodePlace = data;
console.log(data);
}
@ -610,6 +610,13 @@ it would also work to just use on:click on the MapLibre component itself. -->
<DefaultMarker lngLat={marker.lngLat} />
{/each}
</MapLibre>
{#if reverseGeocodePlace}
<div class="mt-2">
<p>{reverseGeocodePlace.id}</p>
<p>{reverseGeocodePlace.region}, {reverseGeocodePlace.country}</p>
<p>{reverseGeocodePlace.is_visited ? 'Visited' : 'Not Visited'}</p>
</div>
{/if}
</div>
</div>
</div>