Update user marker position
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Alessio Davoli 2023-12-13 19:02:00 +01:00
parent 207af1abf1
commit 4d53aabef4

View file

@ -1,6 +1,7 @@
<script lang="ts">
import { onMount, onDestroy } from 'svelte';
import { fade } from 'svelte/transition';
const mapMarkerIcon = new URL('/icons/map.png', import.meta.url).href
export let route;
const pianelloCoordinates = [43.14, 12.53];
@ -17,7 +18,7 @@
const openStreetMapTile = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
let errored = false;
const watchPosition = async () => {
if (!("geolocation" in navigator)) {
errored = true;
@ -39,7 +40,12 @@
longitude = crd.longitude;
accuracy = crd.accuracy;
const userMarker = leaflet.marker([latitude, longitude]).addTo(map);
const icon = leaflet.icon({
iconUrl: mapMarkerIcon,
iconSize: [38, 95], // size of the icon
});
userMarker = leaflet.marker([latitude, longitude], {icon}).addTo(map);
// move the map to have the location in its center
map.panTo(userMarker.getLatLng());