mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-23 06:49:37 +02:00
auto point selection
This commit is contained in:
parent
7d931c7a97
commit
a38887a602
3 changed files with 59 additions and 32 deletions
|
@ -120,6 +120,7 @@
|
||||||
|
|
||||||
{#if isPointModalOpen}
|
{#if isPointModalOpen}
|
||||||
<PointSelectionModal
|
<PointSelectionModal
|
||||||
|
bind:adventure={adventureToEdit}
|
||||||
longitude={adventureToEdit.longitude}
|
longitude={adventureToEdit.longitude}
|
||||||
latitude={adventureToEdit.latitude}
|
latitude={adventureToEdit.latitude}
|
||||||
on:close={() => (isPointModalOpen = false)}
|
on:close={() => (isPointModalOpen = false)}
|
||||||
|
@ -184,6 +185,16 @@
|
||||||
bind:value={adventureToEdit.location}
|
bind:value={adventureToEdit.location}
|
||||||
class="input input-bordered w-full max-w-xs mt-1"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
|
<div class="mb-2 mt-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-secondary"
|
||||||
|
on:click={() => (isPointModalOpen = true)}
|
||||||
|
>
|
||||||
|
{adventureToEdit.latitude && adventureToEdit.longitude ? 'Change' : 'Select'}
|
||||||
|
Location</button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label for="date">Date <Calendar class="inline-block mb-1 w-6 h-6" /></label><br />
|
<label for="date">Date <Calendar class="inline-block mb-1 w-6 h-6" /></label><br />
|
||||||
|
@ -283,16 +294,6 @@
|
||||||
bind:value={adventureToEdit.longitude}
|
bind:value={adventureToEdit.longitude}
|
||||||
class="input input-bordered w-full max-w-xs mt-1"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
<div class="mb-2">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="btn btn-secondary"
|
|
||||||
on:click={() => (isPointModalOpen = true)}
|
|
||||||
>
|
|
||||||
{adventureToEdit.latitude && adventureToEdit.longitude ? 'Change' : 'Select'}
|
|
||||||
Location</button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
{#if adventureToEdit.collection === null}
|
{#if adventureToEdit.collection === null}
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label for="is_public">Public <Earth class="inline-block -mt-1 mb-1 w-6 h-6" /></label
|
<label for="is_public">Public <Earth class="inline-block -mt-1 mb-1 w-6 h-6" /></label
|
||||||
|
|
|
@ -12,8 +12,15 @@
|
||||||
export let longitude: number | null = null;
|
export let longitude: number | null = null;
|
||||||
export let latitude: number | null = null;
|
export let latitude: number | null = null;
|
||||||
|
|
||||||
import Wikipedia from '~icons/mdi/wikipedia';
|
import MapMarker from '~icons/mdi/map-marker';
|
||||||
|
import Calendar from '~icons/mdi/calendar';
|
||||||
|
import Notebook from '~icons/mdi/notebook';
|
||||||
import ClipboardList from '~icons/mdi/clipboard-list';
|
import ClipboardList from '~icons/mdi/clipboard-list';
|
||||||
|
import Star from '~icons/mdi/star';
|
||||||
|
import Attachment from '~icons/mdi/attachment';
|
||||||
|
import Map from '~icons/mdi/map';
|
||||||
|
import Earth from '~icons/mdi/earth';
|
||||||
|
import Wikipedia from '~icons/mdi/wikipedia';
|
||||||
import ActivityComplete from './ActivityComplete.svelte';
|
import ActivityComplete from './ActivityComplete.svelte';
|
||||||
import { appVersion } from '$lib/config';
|
import { appVersion } from '$lib/config';
|
||||||
|
|
||||||
|
@ -152,11 +159,8 @@
|
||||||
isImageFetcherOpen = false;
|
isImageFetcherOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLongLat(event: CustomEvent<[number, number]>) {
|
function setLongLat(event: CustomEvent<Adventure>) {
|
||||||
console.log(event.detail);
|
console.log(event.detail);
|
||||||
newAdventure.latitude = event.detail[1];
|
|
||||||
newAdventure.longitude = event.detail[0];
|
|
||||||
isPointModalOpen = false;
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -165,6 +169,7 @@
|
||||||
query={newAdventure.name}
|
query={newAdventure.name}
|
||||||
on:close={() => (isPointModalOpen = false)}
|
on:close={() => (isPointModalOpen = false)}
|
||||||
on:submit={setLongLat}
|
on:submit={setLongLat}
|
||||||
|
bind:adventure={newAdventure}
|
||||||
latitude={newAdventure.latitude || null}
|
latitude={newAdventure.latitude || null}
|
||||||
longitude={newAdventure.longitude || null}
|
longitude={newAdventure.longitude || null}
|
||||||
/>
|
/>
|
||||||
|
@ -238,9 +243,7 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label for="location"
|
<label for="location">Location<MapMarker class="inline-block -mt-1 mb-1 w-6 h-6" /></label
|
||||||
>Location<iconify-icon icon="mdi:map-marker" class="text-lg ml-0.5 -mb-0.5"
|
|
||||||
></iconify-icon></label
|
|
||||||
><br />
|
><br />
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
@ -249,6 +252,16 @@
|
||||||
bind:value={newAdventure.location}
|
bind:value={newAdventure.location}
|
||||||
class="input input-bordered w-full max-w-xs mt-1"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
|
<div class="mb-2 mt-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-secondary"
|
||||||
|
on:click={() => (isPointModalOpen = true)}
|
||||||
|
><Map class="inline-block w-6 h-6" />{newAdventure.latitude && newAdventure.longitude
|
||||||
|
? 'Change'
|
||||||
|
: 'Select'} Location</button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label for="date"
|
<label for="date"
|
||||||
|
@ -359,14 +372,7 @@
|
||||||
bind:value={newAdventure.longitude}
|
bind:value={newAdventure.longitude}
|
||||||
class="input input-bordered w-full max-w-xs mt-1"
|
class="input input-bordered w-full max-w-xs mt-1"
|
||||||
/>
|
/>
|
||||||
<div class="mb-2">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="btn btn-secondary"
|
|
||||||
on:click={() => (isPointModalOpen = true)}
|
|
||||||
>{newAdventure.latitude && newAdventure.longitude ? 'Change' : 'Select'} Location</button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary mr-4 mt-4">Create</button>
|
<button type="submit" class="btn btn-primary mr-4 mt-4">Create</button>
|
||||||
<button type="button" class="btn mt-4" on:click={close}>Close</button>
|
<button type="button" class="btn mt-4" on:click={close}>Close</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import type { OpenStreetMapPlace, Point } from '$lib/types';
|
import type { Adventure, OpenStreetMapPlace, Point } from '$lib/types';
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
let markers: Point[] = [];
|
let markers: Point[] = [];
|
||||||
|
|
||||||
export let query: string | null = null;
|
export let query: string | null = null;
|
||||||
|
export let adventure: Adventure;
|
||||||
|
|
||||||
if (query) {
|
if (query) {
|
||||||
geocode();
|
geocode();
|
||||||
|
@ -22,7 +23,7 @@
|
||||||
|
|
||||||
function addMarker(e: CustomEvent<MouseEvent>) {
|
function addMarker(e: CustomEvent<MouseEvent>) {
|
||||||
markers = [];
|
markers = [];
|
||||||
markers = [...markers, { lngLat: e.detail.lngLat, name: 'Marker 1' }];
|
markers = [...markers, { lngLat: e.detail.lngLat, name: '' }];
|
||||||
console.log(markers);
|
console.log(markers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +33,13 @@
|
||||||
modal.showModal();
|
modal.showModal();
|
||||||
}
|
}
|
||||||
if (longitude && latitude) {
|
if (longitude && latitude) {
|
||||||
markers = [{ lngLat: { lng: longitude, lat: latitude }, name: 'Marker 1' }];
|
markers = [
|
||||||
|
{
|
||||||
|
lngLat: { lng: longitude, lat: latitude },
|
||||||
|
name: adventure.name,
|
||||||
|
location: adventure.location
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -72,8 +79,19 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let coordArray: [number, number] = [markers[0].lngLat.lng, markers[0].lngLat.lat];
|
let coordArray: [number, number] = [markers[0].lngLat.lng, markers[0].lngLat.lat];
|
||||||
console.log(coordArray);
|
|
||||||
dispatch('submit', coordArray);
|
console.log(markers[0]);
|
||||||
|
adventure.longitude = coordArray[0];
|
||||||
|
adventure.latitude = coordArray[1];
|
||||||
|
if (!adventure.location) {
|
||||||
|
adventure.location = markers[0].location;
|
||||||
|
}
|
||||||
|
if (!adventure.name) {
|
||||||
|
adventure.name = markers[0].name;
|
||||||
|
}
|
||||||
|
adventure.activity_types = [...adventure.activity_types, markers[0].activity_type];
|
||||||
|
dispatch('submit', adventure);
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -120,7 +138,9 @@
|
||||||
markers = [
|
markers = [
|
||||||
{
|
{
|
||||||
lngLat: { lng: Number(place.lon), lat: Number(place.lat) },
|
lngLat: { lng: Number(place.lon), lat: Number(place.lat) },
|
||||||
name: place.display_name
|
location: place.display_name,
|
||||||
|
name: place.name,
|
||||||
|
activity_type: place.type
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue