1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-23 14:59:36 +02:00

Add mark_visited_region action to ReverseGeocodeViewSet and update AdventureModal for region tracking

This commit is contained in:
Sean Morley 2024-11-01 20:08:23 -04:00
parent a7a49227c4
commit b60455b50a
3 changed files with 65 additions and 35 deletions

View file

@ -28,7 +28,6 @@
import ActivityComplete from './ActivityComplete.svelte';
import { appVersion } from '$lib/config';
import { ADVENTURE_TYPES } from '$lib';
import RegionCard from './RegionCard.svelte';
let wikiError: string = '';
@ -82,6 +81,12 @@
images = adventure.images || [];
if (longitude && latitude) {
adventure.latitude = latitude;
adventure.longitude = longitude;
reverseGeocode();
}
if (adventure.longitude && adventure.latitude) {
markers = [];
markers = [
@ -94,12 +99,6 @@
];
}
if (longitude && latitude) {
adventure.latitude = latitude;
adventure.longitude = longitude;
reverseGeocode();
}
$: {
if (!adventure.rating) {
adventure.rating = NaN;
@ -143,23 +142,24 @@
close();
}
let previousCoords: { lat: number; lng: number } | null = null;
$: if (markers.length > 0) {
adventure.latitude = Math.round(markers[0].lngLat.lat * 1e6) / 1e6;
adventure.longitude = Math.round(markers[0].lngLat.lng * 1e6) / 1e6;
if (!adventure.location) {
adventure.location = markers[0].location;
const newLat = Math.round(markers[0].lngLat.lat * 1e6) / 1e6;
const newLng = Math.round(markers[0].lngLat.lng * 1e6) / 1e6;
if (!previousCoords || previousCoords.lat !== newLat || previousCoords.lng !== newLng) {
adventure.latitude = newLat;
adventure.longitude = newLng;
previousCoords = { lat: newLat, lng: newLng };
reverseGeocode();
}
if (!adventure.name) {
adventure.name = markers[0].name;
}
}
$: {
if (adventure.longitude && adventure.latitude) {
reverseGeocode();
}
}
async function fetchImage() {
let res = await fetch(url);
let data = await res.blob();