mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-02 19:55:18 +02:00
commit
9884b2bdee
6 changed files with 18645 additions and 8 deletions
|
@ -108,3 +108,7 @@ AdventureLog is licensed under the GNU General Public License v3.0.
|
|||
- Password reset functionality
|
||||
- Improved error handling
|
||||
- Handling of adventure cards with variable width -->
|
||||
|
||||
# Attribution
|
||||
|
||||
- [Mexico GEOJSON](https://cartographyvectors.com/map/784-mexico-with-states)
|
||||
|
|
18584
backend/server/static/data/mx.json
Normal file
18584
backend/server/static/data/mx.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -174,16 +174,17 @@ class Command(BaseCommand):
|
|||
('MX-CAM', 'Campeche', 'mx'),
|
||||
('MX-CHP', 'Chiapas', 'mx'),
|
||||
('MX-CHH', 'Chihuahua', 'mx'),
|
||||
('MX-COA', 'Coahuila', 'mx'),
|
||||
('MX-CMX', 'Ciudad de México', 'mx'),
|
||||
('MX-COA', 'Coahuila de Zaragoza', 'mx'),
|
||||
('MX-COL', 'Colima', 'mx'),
|
||||
('MX-DUR', 'Durango', 'mx'),
|
||||
('MX-GUA', 'Guanajuato', 'mx'),
|
||||
('MX-GRO', 'Guerrero', 'mx'),
|
||||
('MX-HID', 'Hidalgo', 'mx'),
|
||||
('MX-JAL', 'Jalisco', 'mx'),
|
||||
('MX-MEX', 'State of Mexico', 'mx'),
|
||||
('MX-MIC', 'Michoacán', 'mx'),
|
||||
('MX-MIC', 'Michoacán de Ocampo', 'mx'),
|
||||
('MX-MOR', 'Morelos', 'mx'),
|
||||
('MX-MEX', 'México', 'mx'),
|
||||
('MX-NAY', 'Nayarit', 'mx'),
|
||||
('MX-NLE', 'Nuevo León', 'mx'),
|
||||
('MX-OAX', 'Oaxaca', 'mx'),
|
||||
|
@ -196,7 +197,7 @@ class Command(BaseCommand):
|
|||
('MX-TAB', 'Tabasco', 'mx'),
|
||||
('MX-TAM', 'Tamaulipas', 'mx'),
|
||||
('MX-TLA', 'Tlaxcala', 'mx'),
|
||||
('MX-VER', 'Veracruz', 'mx'),
|
||||
('MX-VER', 'Veracruz de Ignacio de la Llave', 'mx'),
|
||||
('MX-YUC', 'Yucatán', 'mx'),
|
||||
('MX-ZAC', 'Zacatecas', 'mx'),
|
||||
('JP-01', 'Hokkaido', 'jp'),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import type { Adventure, Point } from '$lib/types';
|
||||
import type { Adventure, OpenStreetMapPlace, Point } from '$lib/types';
|
||||
import { onMount } from 'svelte';
|
||||
import { enhance } from '$app/forms';
|
||||
import { addToast } from '$lib/toasts';
|
||||
|
@ -15,6 +15,7 @@
|
|||
import Wikipedia from '~icons/mdi/wikipedia';
|
||||
import ClipboardList from '~icons/mdi/clipboard-list';
|
||||
import ActivityComplete from './ActivityComplete.svelte';
|
||||
import { appVersion } from '$lib/config';
|
||||
|
||||
let newAdventure: Adventure = {
|
||||
id: NaN,
|
||||
|
@ -37,6 +38,25 @@
|
|||
if (longitude && latitude) {
|
||||
newAdventure.latitude = latitude;
|
||||
newAdventure.longitude = longitude;
|
||||
reverseGeocode();
|
||||
}
|
||||
|
||||
async function reverseGeocode() {
|
||||
let res = await fetch(
|
||||
`https://nominatim.openstreetmap.org/search?q=${newAdventure.latitude},${newAdventure.longitude}&format=jsonv2`,
|
||||
{
|
||||
headers: {
|
||||
'User-Agent': `AdventureLog / ${appVersion} `
|
||||
}
|
||||
}
|
||||
);
|
||||
let data = (await res.json()) as OpenStreetMapPlace[];
|
||||
if (data.length > 0) {
|
||||
newAdventure.name = data[0]?.name || '';
|
||||
newAdventure.activity_types?.push(data[0]?.type || '');
|
||||
newAdventure.location = data[0]?.display_name || '';
|
||||
}
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
let image: 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 = ['FR', 'US', 'CA', 'DE', 'AU'];
|
||||
let countryCodesToFetch = ['FR', 'US', 'CA', 'DE', 'AU', 'MX'];
|
||||
let geoJSON = {
|
||||
type: 'FeatureCollection',
|
||||
features: []
|
||||
|
|
|
@ -30,7 +30,34 @@
|
|||
newLatitude = e.detail.lngLat.lat;
|
||||
}
|
||||
|
||||
let markers = data.props.markers;
|
||||
let markers = [];
|
||||
|
||||
$: {
|
||||
markers = data.props.markers;
|
||||
}
|
||||
|
||||
function createNewAdventure(event) {
|
||||
// markers = visited
|
||||
// .filter((adventure) => adventure.latitude !== null && adventure.longitude !== null)
|
||||
// .map((adventure) => {
|
||||
// return {
|
||||
// lngLat: [adventure.longitude, adventure.latitude] as [number, number],
|
||||
// name: adventure.name,
|
||||
// type: adventure.type
|
||||
// };
|
||||
// });
|
||||
console.log(event.detail);
|
||||
|
||||
let newMarker = {
|
||||
lngLat: [event.detail.longitude, event.detail.latitude],
|
||||
name: event.detail.name,
|
||||
type: 'planned'
|
||||
};
|
||||
markers = [...markers, newMarker];
|
||||
clearMarkers();
|
||||
console.log(markers);
|
||||
createModalOpen = false;
|
||||
}
|
||||
|
||||
let visitedRegions = data.props.visitedRegions;
|
||||
|
||||
|
@ -71,6 +98,7 @@
|
|||
on:close={() => (createModalOpen = false)}
|
||||
longitude={newLongitude}
|
||||
latitude={newLatitude}
|
||||
on:create={createNewAdventure}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
|
@ -82,7 +110,7 @@
|
|||
class="relative aspect-[9/16] max-h-[70vh] w-full sm:aspect-video sm:max-h-full"
|
||||
standardControls
|
||||
>
|
||||
{#each data.props.markers as { lngLat, name, type }}
|
||||
{#each markers as { lngLat, name, type }}
|
||||
{#if type == 'visited'}
|
||||
<Marker
|
||||
{lngLat}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue