@fix
This commit is contained in:
parent
7cdcdda027
commit
eedc252877
|
@ -6,7 +6,6 @@
|
|||
export let lat = 0
|
||||
export let 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
|
||||
let Mlat = [lat - round, lat + round]
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
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 NumberForm from './NumberForm.svelte'
|
||||
import SingleForm from './SingleChoiceForm.svelte'
|
||||
|
@ -36,6 +36,7 @@
|
|||
}
|
||||
|
||||
export let gameData = {} //data
|
||||
$: console.log(gameData.questions)
|
||||
|
||||
$: answers = parseQuestion(gameData.questions[clientAnswers.pos].answer, gameData.questions[clientAnswers.pos].type) //delete
|
||||
let page
|
||||
|
@ -68,11 +69,28 @@
|
|||
$: lng = Number.parseFloat($data.questions[clientAnswers.pos].lng)
|
||||
|
||||
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>
|
||||
|
||||
{#if !startQuestion}
|
||||
<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>
|
||||
{/if}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
import Renderer from './Forms/Renderer.svelte'
|
||||
import Redirect from '../../lib/Components/common/Redirect.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
|
||||
|
||||
|
@ -27,6 +27,10 @@
|
|||
?.map((q) => q.thumbnail)
|
||||
|
||||
let view = 'game-loading'
|
||||
|
||||
//is user already in game
|
||||
const userInGame = JSON.parse(localStorage.getItem(location.pathname))
|
||||
$: if ($gameData && userInGame) view = 'game-play'
|
||||
</script>
|
||||
|
||||
{#if view === 'game-loading'}
|
||||
|
@ -69,7 +73,7 @@
|
|||
<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 }}>
|
||||
{#each $gameData.data.questions as { lat, lng }}
|
||||
<Circle {lat} {lng} />
|
||||
<Marker {lat} {lng} />
|
||||
{/each}
|
||||
<GeolocateControl
|
||||
on:geolocate={(e) => {
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
import NavigationBarLayout from '$lib/Components/Layouts/NavigationBarLayout.svelte'
|
||||
|
||||
let user = { lat: 50.073658, lng: 14.41854 }
|
||||
|
||||
const lastGame = localStorage.getItem('lastGame')
|
||||
if (lastGame) {
|
||||
location.href = lastGame
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavigationBarLayout>
|
||||
|
|
Loading…
Reference in New Issue