@fix #42

Merged
Ota-Prokopec merged 1 commits from mapfix into master 2022-12-18 11:22:33 +00:00
4 changed files with 31 additions and 5 deletions
Showing only changes of commit eedc252877 - Show all commits

View File

@ -6,7 +6,6 @@
export let lat = 0 export let lat = 0
export let lng = 0 export let lng = 0
export let user = { lat: 0, lng: 0 } export let user = { lat: 0, lng: 0 }
$: console.log({ user, lng, lat })
export let round = (1 / 110.574 / 1000) * 5 //cca 12m nutno pozměnit!!!!!!!!!! tento komentář nemazat export let round = (1 / 110.574 / 1000) * 5 //cca 12m nutno pozměnit!!!!!!!!!! tento komentář nemazat
let Mlat = [lat - round, lat + round] let Mlat = [lat - round, lat + round]

View File

@ -1,6 +1,6 @@
<script> <script>
import parseQuestion from '../../../lib/utils/parseQuestion' import parseQuestion from '../../../lib/utils/parseQuestion'
import Circle from './../../../lib/Components/Map/Circle.svelte' import Marker from '../../../lib/Components/Map/Marker.svelte'
import TextForm from './TextForm.svelte' import TextForm from './TextForm.svelte'
import NumberForm from './NumberForm.svelte' import NumberForm from './NumberForm.svelte'
import SingleForm from './SingleChoiceForm.svelte' import SingleForm from './SingleChoiceForm.svelte'
@ -36,6 +36,7 @@
} }
export let gameData = {} //data export let gameData = {} //data
$: console.log(gameData.questions)
$: answers = parseQuestion(gameData.questions[clientAnswers.pos].answer, gameData.questions[clientAnswers.pos].type) //delete $: answers = parseQuestion(gameData.questions[clientAnswers.pos].answer, gameData.questions[clientAnswers.pos].type) //delete
let page let page
@ -68,11 +69,28 @@
$: lng = Number.parseFloat($data.questions[clientAnswers.pos].lng) $: lng = Number.parseFloat($data.questions[clientAnswers.pos].lng)
let user = { lat: null, lng: null } let user = { lat: null, lng: null }
//set user to localstorage
$: if (clientAnswers.pos + 1 !== clientAnswers.end) {
const data = JSON.stringify({
numberOfQuestion: clientAnswers.pos,
})
localStorage.setItem(`/${gameData.url}`, data)
localStorage.setItem('lastGame', `/${gameData.url}`)
}
//is user already in game
const userInGame = JSON.parse(localStorage.getItem(location.pathname))
if (userInGame) {
const { numberOfQuestion } = userInGame
clientAnswers.pos = numberOfQuestion
}
$: console.log(clientAnswers.pos)
</script> </script>
{#if !startQuestion} {#if !startQuestion}
<Erantmap center={{ lat, lng }} bind:user class="w-full h-full"> <Erantmap center={{ lat, lng }} bind:user class="w-full h-full">
<Circle on:enter={() => (startQuestion = true)} {lat} {lng} {user} /> <Marker on:enter={() => (startQuestion = true)} {lat} {lng} {user} />
</Erantmap> </Erantmap>
{/if} {/if}

View File

@ -14,7 +14,7 @@
import Renderer from './Forms/Renderer.svelte' import Renderer from './Forms/Renderer.svelte'
import Redirect from '../../lib/Components/common/Redirect.svelte' import Redirect from '../../lib/Components/common/Redirect.svelte'
import ImageSlider from '../../lib/Components/common/ImageSlider.svelte' import ImageSlider from '../../lib/Components/common/ImageSlider.svelte'
import Circle from '../../lib/Components/Map/Circle.svelte' import Marker from '../../lib/Components/Map/Marker.svelte'
export let gameurl export let gameurl
@ -27,6 +27,10 @@
?.map((q) => q.thumbnail) ?.map((q) => q.thumbnail)
let view = 'game-loading' let view = 'game-loading'
//is user already in game
const userInGame = JSON.parse(localStorage.getItem(location.pathname))
$: if ($gameData && userInGame) view = 'game-play'
</script> </script>
{#if view === 'game-loading'} {#if view === 'game-loading'}
@ -69,7 +73,7 @@
<div class="px-4 m-auto" style="max-width: var(--max-viewport-width);"> <div class="px-4 m-auto" style="max-width: var(--max-viewport-width);">
<Map radius class="w-full h-44" center={{ lng: $gameData.data.lng, lat: $gameData.data.lat }}> <Map radius class="w-full h-44" center={{ lng: $gameData.data.lng, lat: $gameData.data.lat }}>
{#each $gameData.data.questions as { lat, lng }} {#each $gameData.data.questions as { lat, lng }}
<Circle {lat} {lng} /> <Marker {lat} {lng} />
{/each} {/each}
<GeolocateControl <GeolocateControl
on:geolocate={(e) => { on:geolocate={(e) => {

View File

@ -3,6 +3,11 @@
import NavigationBarLayout from '$lib/Components/Layouts/NavigationBarLayout.svelte' import NavigationBarLayout from '$lib/Components/Layouts/NavigationBarLayout.svelte'
let user = { lat: 50.073658, lng: 14.41854 } let user = { lat: 50.073658, lng: 14.41854 }
const lastGame = localStorage.getItem('lastGame')
if (lastGame) {
location.href = lastGame
}
</script> </script>
<NavigationBarLayout> <NavigationBarLayout>