mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-19 12:59:36 +02:00
Fix map filtering
This commit is contained in:
parent
ffde90e6f5
commit
8a77cd98bb
1 changed files with 6 additions and 22 deletions
|
@ -19,21 +19,10 @@
|
||||||
let showVisited = true;
|
let showVisited = true;
|
||||||
let showPlanned = true;
|
let showPlanned = true;
|
||||||
|
|
||||||
$: {
|
$: filteredMarkers = markers.filter(
|
||||||
if (!showVisited) {
|
(marker) =>
|
||||||
markers = data.props.markers.filter((marker) => marker.type !== 'visited');
|
(showVisited && marker.type === 'visited') || (showPlanned && marker.type === 'planned')
|
||||||
} else {
|
);
|
||||||
const visitedMarkers = data.props.markers.filter((marker) => marker.type === 'visited');
|
|
||||||
markers = [...markers, ...visitedMarkers];
|
|
||||||
}
|
|
||||||
if (!showPlanned) {
|
|
||||||
markers = data.props.markers.filter((marker) => marker.type !== 'planned');
|
|
||||||
} else {
|
|
||||||
const plannedMarkers = data.props.markers.filter((marker) => marker.type === 'planned');
|
|
||||||
markers = [...markers, ...plannedMarkers];
|
|
||||||
}
|
|
||||||
console.log(markers);
|
|
||||||
}
|
|
||||||
|
|
||||||
let newMarker = [];
|
let newMarker = [];
|
||||||
|
|
||||||
|
@ -43,7 +32,6 @@
|
||||||
function addMarker(e) {
|
function addMarker(e) {
|
||||||
newMarker = [];
|
newMarker = [];
|
||||||
newMarker = [...newMarker, { lngLat: e.detail.lngLat, name: 'Marker 1' }];
|
newMarker = [...newMarker, { lngLat: e.detail.lngLat, name: 'Marker 1' }];
|
||||||
console.log(newMarker);
|
|
||||||
newLongitude = e.detail.lngLat.lng;
|
newLongitude = e.detail.lngLat.lng;
|
||||||
newLatitude = e.detail.lngLat.lat;
|
newLatitude = e.detail.lngLat.lat;
|
||||||
}
|
}
|
||||||
|
@ -55,19 +43,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNewAdventure(event) {
|
function createNewAdventure(event) {
|
||||||
console.log(event.detail);
|
|
||||||
|
|
||||||
let newMarker = {
|
let newMarker = {
|
||||||
lngLat: [event.detail.longitude, event.detail.latitude],
|
lngLat: [event.detail.longitude, event.detail.latitude],
|
||||||
name: event.detail.name,
|
name: event.detail.name,
|
||||||
type: 'planned'
|
type: event.detail.type
|
||||||
};
|
};
|
||||||
markers = [...markers, newMarker];
|
markers = [...markers, newMarker];
|
||||||
clearMarkers();
|
clearMarkers();
|
||||||
console.log(markers);
|
|
||||||
createModalOpen = false;
|
createModalOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let visitedRegions = data.props.visitedRegions;
|
let visitedRegions = data.props.visitedRegions;
|
||||||
|
|
||||||
let geoJSON = [];
|
let geoJSON = [];
|
||||||
|
@ -154,7 +138,7 @@
|
||||||
class="relative aspect-[9/16] max-h-[70vh] w-full sm:aspect-video sm:max-h-full"
|
class="relative aspect-[9/16] max-h-[70vh] w-full sm:aspect-video sm:max-h-full"
|
||||||
standardControls
|
standardControls
|
||||||
>
|
>
|
||||||
{#each markers as { lngLat, name, type }}
|
{#each filteredMarkers as { lngLat, name, type }}
|
||||||
{#if type == 'visited'}
|
{#if type == 'visited'}
|
||||||
<Marker
|
<Marker
|
||||||
{lngLat}
|
{lngLat}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue