mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-25 07:49:37 +02:00
feat: Add latitude and longitude to NewAdventure component
This commit is contained in:
parent
31063c92cb
commit
3e328f408a
2 changed files with 64 additions and 0 deletions
|
@ -9,6 +9,9 @@
|
|||
|
||||
export let type: string = 'visited';
|
||||
|
||||
export let longitude: number | undefined = undefined;
|
||||
export let latitude: number | undefined = undefined;
|
||||
|
||||
import Wikipedia from '~icons/mdi/wikipedia';
|
||||
import ClipboardList from '~icons/mdi/clipboard-list';
|
||||
import ActivityComplete from './ActivityComplete.svelte';
|
||||
|
@ -31,6 +34,11 @@
|
|||
collection: null
|
||||
};
|
||||
|
||||
if (longitude && latitude) {
|
||||
newAdventure.latitude = latitude;
|
||||
newAdventure.longitude = longitude;
|
||||
}
|
||||
|
||||
let image: File;
|
||||
let fileInput: HTMLInputElement;
|
||||
|
||||
|
@ -164,6 +172,28 @@
|
|||
on:submit={handleSubmit}
|
||||
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
|
||||
type="text"
|
||||
name="type"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<script>
|
||||
// @ts-nocheck
|
||||
|
||||
import NewAdventure from '$lib/components/NewAdventure.svelte';
|
||||
import {
|
||||
DefaultMarker,
|
||||
MapEvents,
|
||||
|
@ -16,6 +17,19 @@
|
|||
|
||||
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 visitedRegions = data.props.visitedRegions;
|
||||
|
@ -31,8 +45,24 @@
|
|||
|
||||
// mapped to the checkbox
|
||||
let showGEO = true;
|
||||
|
||||
let createModalOpen = false;
|
||||
</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>
|
||||
<input type="checkbox" id="shpw-gep" name="show-geo" class="checkbox" bind:checked={showGEO} />
|
||||
|
||||
|
@ -109,6 +139,10 @@
|
|||
/> -->
|
||||
</GeoJSON>
|
||||
{/if}
|
||||
<MapEvents on:click={addMarker} />
|
||||
{#each newMarker as marker}
|
||||
<DefaultMarker lngLat={marker.lngLat} />
|
||||
{/each}
|
||||
</MapLibre>
|
||||
|
||||
<style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue