mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-22 22:39:36 +02:00
auto point selection
This commit is contained in:
parent
7d931c7a97
commit
a38887a602
3 changed files with 59 additions and 32 deletions
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
// @ts-nocheck
|
||||
import type { OpenStreetMapPlace, Point } from '$lib/types';
|
||||
import type { Adventure, OpenStreetMapPlace, Point } from '$lib/types';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
const dispatch = createEventDispatcher();
|
||||
import { onMount } from 'svelte';
|
||||
|
@ -12,6 +12,7 @@
|
|||
let markers: Point[] = [];
|
||||
|
||||
export let query: string | null = null;
|
||||
export let adventure: Adventure;
|
||||
|
||||
if (query) {
|
||||
geocode();
|
||||
|
@ -22,7 +23,7 @@
|
|||
|
||||
function addMarker(e: CustomEvent<MouseEvent>) {
|
||||
markers = [];
|
||||
markers = [...markers, { lngLat: e.detail.lngLat, name: 'Marker 1' }];
|
||||
markers = [...markers, { lngLat: e.detail.lngLat, name: '' }];
|
||||
console.log(markers);
|
||||
}
|
||||
|
||||
|
@ -32,7 +33,13 @@
|
|||
modal.showModal();
|
||||
}
|
||||
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;
|
||||
}
|
||||
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>
|
||||
|
||||
|
@ -120,7 +138,9 @@
|
|||
markers = [
|
||||
{
|
||||
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