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

feat: Add latitude and longitude to NewAdventure component

This commit is contained in:
Sean Morley 2024-07-24 18:45:49 -04:00
parent 31063c92cb
commit 3e328f408a
2 changed files with 64 additions and 0 deletions

View file

@ -9,6 +9,9 @@
export let type: string = 'visited'; export let type: string = 'visited';
export let longitude: number | undefined = undefined;
export let latitude: number | undefined = undefined;
import Wikipedia from '~icons/mdi/wikipedia'; import Wikipedia from '~icons/mdi/wikipedia';
import ClipboardList from '~icons/mdi/clipboard-list'; import ClipboardList from '~icons/mdi/clipboard-list';
import ActivityComplete from './ActivityComplete.svelte'; import ActivityComplete from './ActivityComplete.svelte';
@ -31,6 +34,11 @@
collection: null collection: null
}; };
if (longitude && latitude) {
newAdventure.latitude = latitude;
newAdventure.longitude = longitude;
}
let image: File; let image: File;
let fileInput: HTMLInputElement; let fileInput: HTMLInputElement;
@ -164,6 +172,28 @@
on:submit={handleSubmit} on:submit={handleSubmit}
action="/adventures?/create" action="/adventures?/create"
> >
<div class="join">
<input
class="join-item btn btn-neutral"
type="radio"
name="type"
id="visited"
value="visited"
aria-label="Visited"
checked
on:click={() => (type = 'visited')}
/>
<input
class="join-item btn btn-neutral"
type="radio"
name="type"
id="planned"
value="planned"
aria-label="Planned"
on:click={() => (type = 'planned')}
/>
</div>
<input <input
type="text" type="text"
name="type" name="type"

View file

@ -1,6 +1,7 @@
<script> <script>
// @ts-nocheck // @ts-nocheck
import NewAdventure from '$lib/components/NewAdventure.svelte';
import { import {
DefaultMarker, DefaultMarker,
MapEvents, MapEvents,
@ -16,6 +17,19 @@
let clickedName = ''; let clickedName = '';
let newMarker = [];
let newLongitude = null;
let newLatitude = null;
function addMarker(e) {
newMarker = [];
newMarker = [...newMarker, { lngLat: e.detail.lngLat, name: 'Marker 1' }];
console.log(newMarker);
newLongitude = e.detail.lngLat.lng;
newLatitude = e.detail.lngLat.lat;
}
let markers = data.props.markers; let markers = data.props.markers;
let visitedRegions = data.props.visitedRegions; let visitedRegions = data.props.visitedRegions;
@ -31,8 +45,24 @@
// mapped to the checkbox // mapped to the checkbox
let showGEO = true; let showGEO = true;
let createModalOpen = false;
</script> </script>
{#if newMarker.length > 0}
<button type="button" class="btn btn-primary" on:click={() => (createModalOpen = true)}
>Add New Adventure at Marker</button
>
{/if}
{#if createModalOpen}
<NewAdventure
on:close={() => (createModalOpen = false)}
longitude={newLongitude}
latitude={newLatitude}
/>
{/if}
<label for="show-geo">Show Borders?</label> <label for="show-geo">Show Borders?</label>
<input type="checkbox" id="shpw-gep" name="show-geo" class="checkbox" bind:checked={showGEO} /> <input type="checkbox" id="shpw-gep" name="show-geo" class="checkbox" bind:checked={showGEO} />
@ -109,6 +139,10 @@
/> --> /> -->
</GeoJSON> </GeoJSON>
{/if} {/if}
<MapEvents on:click={addMarker} />
{#each newMarker as marker}
<DefaultMarker lngLat={marker.lngLat} />
{/each}
</MapLibre> </MapLibre>
<style> <style>