diff --git a/src/app/globals.css b/src/app/globals.css index 419c601..640a21f 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -97,4 +97,24 @@ a { flex-direction: column; align-items: center; justify-content: center; -} \ No newline at end of file +} + +.maplibregl-user-location-dot::before { + display: none !important; +} + +.maplibregl-user-location-dot::after { + display: none !important; +} + +.maplibregl-user-location-dot { + background-image: url('/icons/person.svg') !important; + background-size: contain !important; + background-repeat: no-repeat !important; + background-position: center !important; + background-color: transparent !important; + box-shadow: none !important; + border: none !important; + width: 42px !important; + height: 42px !important; +} diff --git a/src/components/MapView.tsx b/src/components/MapView.tsx index 917c200..a664f93 100644 --- a/src/components/MapView.tsx +++ b/src/components/MapView.tsx @@ -1,6 +1,6 @@ 'use client'; -import React, { useEffect, useRef, useState, useCallback } from 'react'; +import React, { useEffect, useRef, useState, useCallback, createElement } from 'react'; import * as maplibregl from 'maplibre-gl'; import 'maplibre-gl/dist/maplibre-gl.css'; import styles from '@/css/MapView.module.css'; @@ -73,7 +73,7 @@ export default function MapView({ source: 'osm-tiles', minzoom: 0, maxzoom: 19, - }, + } ], }; @@ -86,14 +86,21 @@ export default function MapView({ map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }), 'bottom-right'); + const el = document.createElement("img"); + el.src = "/icons/person.svg"; + el.alt = "You"; + el.width = 42; + el.className = styles["sword"]; + const geolocate = new maplibregl.GeolocateControl({ positionOptions: { enableHighAccuracy: true, }, trackUserLocation: true, showUserLocation: true, - showAccuracyCircle: true, + showAccuracyCircle: false, }); + geolocate._dotElement = el; map.addControl(geolocate, 'bottom-right'); map.addControl(new maplibregl.ScaleControl({ unit: 'metric' }), 'bottom-left'); @@ -135,15 +142,21 @@ export default function MapView({ markers.forEach((markerData) => { if (!currentMarkers.has(markerData.id)) { - const popup = new maplibregl.Popup({ offset: 25, className: styles["marker"] }).setHTML( + /*const popup = new maplibregl.Popup({ offset: 25, className: styles["marker"] }).setHTML( `${markerData.title}${ markerData.description ? `
${markerData.description}
` : '' }` - ); + );*/ - const newMarker = new maplibregl.Marker({ color: '#e11d48', }) + const el = document.createElement("img"); + el.src = "/icons/Schwert-gps.svg"; + el.alt = "GPS Point"; + el.width = 80; + el.className = styles["sword"]; + + const newMarker = new maplibregl.Marker({ element: el, anchor: "bottom" }) .setLngLat([markerData.lng, markerData.lat]) - .setPopup(popup) + //.setPopup(popup) .addTo(map); newMarker.getElement().addEventListener('click', () => { diff --git a/src/components/screens/Tour.tsx b/src/components/screens/Tour.tsx index 66b10fa..6471a7c 100644 --- a/src/components/screens/Tour.tsx +++ b/src/components/screens/Tour.tsx @@ -27,53 +27,42 @@ export default function Tour() { const [ test, setTest ] = useState(false); useEffect(() => { - let timerId: string | number | NodeJS.Timeout | undefined; + let timerId: string | number | NodeJS.Timeout | undefined; - const requestPosition = () => { - timerId = setTimeout(() => { - navigator.geolocation.getCurrentPosition( - (position) => { - setMarkers([{ - id: "riddle_one", - title: "Erstes Rätsel", - description: "Test Punkt verschoben vom Standort", - lng: position.coords.longitude + 0.002, - lat: position.coords.latitude, - }]); - }, - (error) => { - requestPosition(); - } - ); - }, 500); - }; + const requestPosition = () => { + timerId = setTimeout(() => { + navigator.geolocation.getCurrentPosition( + (position) => { + setMarkers([{ + id: "riddle_one", + title: "Erstes Rätsel", + description: "Test Punkt verschoben vom Standort", + lng: position.coords.longitude + 0.002, + lat: position.coords.latitude, + }]); + }, + (error) => { + requestPosition(); + } + ); + }, 500); + }; - requestPosition(); + requestPosition(); - return () => clearTimeout(timerId); -}, []); + return () => clearTimeout(timerId); + }, []); - return ( + return ({"Ruf: " + points}
-{"Players: " + playersStr}
-