This commit is contained in:
Jake Kasper
2025-09-05 12:22:01 -04:00
parent e1340a1e50
commit 3fc77a0683

View File

@@ -561,7 +561,7 @@ const PropertyDetail = () => {
if (!navigator.geolocation) { toast.error('GPS not available'); return; } if (!navigator.geolocation) { toast.error('GPS not available'); return; }
// Prefer most accurate recent fix from warm watch; fall back to immediate read // Prefer most accurate recent fix from warm watch; fall back to immediate read
const candidate = bestRecentSample(); const candidate = bestRecentSample();
const useFix = (lat, lng, acc) => { const applyFix = (lat, lng, acc) => {
setGpsAccuracy(acc || null); setGpsAccuracy(acc || null);
setGpsTracePoints(prev => { setGpsTracePoints(prev => {
const normalized = acceptAndNormalizePoint(lat, lng, acc, prev); const normalized = acceptAndNormalizePoint(lat, lng, acc, prev);
@@ -581,12 +581,12 @@ const PropertyDetail = () => {
}; };
if (candidate) { if (candidate) {
const [lat, lng, acc] = candidate; const [lat, lng, acc] = candidate;
useFix(lat, lng, acc); applyFix(lat, lng, acc);
} else { } else {
navigator.geolocation.getCurrentPosition((pos) => { navigator.geolocation.getCurrentPosition((pos) => {
const { latitude, longitude, accuracy } = pos.coords; const { latitude, longitude, accuracy } = pos.coords;
addSampleAndSmooth(latitude, longitude, accuracy); addSampleAndSmooth(latitude, longitude, accuracy);
useFix(latitude, longitude, accuracy); applyFix(latitude, longitude, accuracy);
}, (err)=>{ }, (err)=>{
console.warn('GPS error', err?.message); console.warn('GPS error', err?.message);
toast.error('GPS error: ' + (err?.message || 'unknown')); toast.error('GPS error: ' + (err?.message || 'unknown'));