if (window.Routiz?.explore?.map?.map) {
const map = window.Routiz.explore.map.map;
// lisa Geolocate kontroll (sinine punkt)
const geolocateControl = new mapboxgl.GeolocateControl({
positionOptions: {
enableHighAccuracy: true
},
trackUserLocation: true, // marker liigub koos kasutajaga
showUserHeading: true
});
map.addControl(geolocateControl);
// automaatselt leiab su asukoha esimesel laadimisel
geolocateControl.on('geolocate', function(e) {
console.log('User location:', e.coords.latitude, e.coords.longitude);
});
}