iv1071 commited on
Commit
e94cb69
·
verified ·
1 Parent(s): c183246

🐳 11/02 - 13:03 - Perdonami, ho dimenticato una cosa ma non è di primaria importanza: ieri durante il test ho notato che il percorso del segnale sulla mappa non viene "seguito", come sui navigatori d

Browse files
Files changed (1) hide show
  1. index.html +23 -2
index.html CHANGED
@@ -106,6 +106,9 @@
106
  <i data-lucide="download" class="w-5 h-5"></i>
107
  </button>
108
 
 
 
 
109
  <button onclick="clearData()" class="bg-gray-500 hover:bg-gray-600 text-white font-semibold py-3 px-4 rounded-xl flex items-center gap-2 transition-all active:scale-95">
110
  <i data-lucide="trash-2" class="w-5 h-5"></i>
111
  </button>
@@ -123,6 +126,10 @@
123
  <option value="20">20 m/s² (Solo forti)</option>
124
  </select>
125
  </div>
 
 
 
 
126
  <div class="flex items-center gap-2">
127
  <input type="checkbox" id="privacy-toggle" class="w-4 h-4 rounded border-gray-300" checked>
128
  <label for="privacy-toggle" class="text-xs text-gray-600">Privacy: offset ±10m su export</label>
@@ -694,6 +701,11 @@
694
  }, 30000);
695
  }
696
 
 
 
 
 
 
697
  function updateUserPosition(pos) {
698
  if (!userMarker) {
699
  userMarker = L.circleMarker([pos.lat, pos.lng], {
@@ -708,11 +720,20 @@
708
  userMarker.setLatLng([pos.lat, pos.lng]);
709
  }
710
 
711
- // Centra la mappa solo se è la prima volta o se l'utente lo richiede (auto-center opzionale)
712
- if (pathCoordinates.length < 2) {
 
713
  map.setView([pos.lat, pos.lng], 17);
714
  }
715
  }
 
 
 
 
 
 
 
 
716
 
717
  function renderBumpsList() {
718
  const container = document.getElementById('bumps-list');
 
106
  <i data-lucide="download" class="w-5 h-5"></i>
107
  </button>
108
 
109
+ <button onclick="recenterMap()" class="bg-indigo-500 hover:bg-indigo-600 text-white font-semibold py-3 px-4 rounded-xl flex items-center gap-2 transition-all active:scale-95" title="Centra mappa">
110
+ <i data-lucide="crosshair" class="w-5 h-5"></i>
111
+ </button>
112
  <button onclick="clearData()" class="bg-gray-500 hover:bg-gray-600 text-white font-semibold py-3 px-4 rounded-xl flex items-center gap-2 transition-all active:scale-95">
113
  <i data-lucide="trash-2" class="w-5 h-5"></i>
114
  </button>
 
126
  <option value="20">20 m/s² (Solo forti)</option>
127
  </select>
128
  </div>
129
+ <div class="flex items-center gap-2">
130
+ <input type="checkbox" id="follow-toggle" class="w-4 h-4 rounded border-gray-300" checked>
131
+ <label for="follow-toggle" class="text-xs text-gray-600">Segui posizione (come navigatore)</label>
132
+ </div>
133
  <div class="flex items-center gap-2">
134
  <input type="checkbox" id="privacy-toggle" class="w-4 h-4 rounded border-gray-300" checked>
135
  <label for="privacy-toggle" class="text-xs text-gray-600">Privacy: offset ±10m su export</label>
 
701
  }, 30000);
702
  }
703
 
704
+ let userHasMovedMap = false;
705
+
706
+ // Traccia se l'utente ha mosso manualmente la mappa
707
+ map.on('dragstart', () => { userHasMovedMap = true; });
708
+
709
  function updateUserPosition(pos) {
710
  if (!userMarker) {
711
  userMarker = L.circleMarker([pos.lat, pos.lng], {
 
720
  userMarker.setLatLng([pos.lat, pos.lng]);
721
  }
722
 
723
+ // Auto-follow: se il toggle è attivo E l'utente non ha mosso manualmente la mappa
724
+ const autoFollow = document.getElementById('follow-toggle')?.checked ?? true;
725
+ if (autoFollow && !userHasMovedMap) {
726
  map.setView([pos.lat, pos.lng], 17);
727
  }
728
  }
729
+
730
+ // Bottone per ricentrare manualmente
731
+ function recenterMap() {
732
+ if (currentPosition) {
733
+ map.setView([currentPosition.lat, currentPosition.lng], 17);
734
+ userHasMovedMap = false; // Resetta il flag
735
+ }
736
+ }
737
 
738
  function renderBumpsList() {
739
  const container = document.getElementById('bumps-list');