A browser location is an estimate with an accuracy radius, time, and permission context. It is not proof that a person physically visited a site. A request can time out, be denied, return stale cached coordinates, or continue updating if a watch remains active. Decide whether the task needs one reading or ongoing updates. High-accuracy mode may use more battery and wait longer. The product should state what is stored and for how long, then collect the least precise location that still serves the case workflow.
Geolocation Accuracy, Cancellation, and Retention
Working case
For case 47, an operator can Add approximate place. The UI first offers manual district entry and an optional Use current position button. A one-shot request has a bounded timeout; the result displays an accuracy description and allows correction before submission. If the browser returns a cached position older than the intake policy permits, the operator retries or enters a place manually. The case record stores a coarse place label when that is enough for dispatch, not raw latitude and longitude merely because the API supplied them.
Implementation boundary
Set a deliberate timeout and maximum-age policy for a one-shot request, and show a cancel route even though cancellation of a pending one-shot call may depend on browser behavior. For continuous tracking, retain the watch identifier and call clearWatch on stop, route change, and account switch. Ignore late callbacks after the request is no longer relevant. Do not treat browser coordinates as a server-trusted authorization input. Validate the submitted value, constrain access to stored location, and remove precise coordinates when the approved retention purpose ends.
function locationDecision(reading, maximumAgeMs, nowMs) {
if (!reading || nowMs - reading.timestamp > maximumAgeMs) return "manual-or-retry";
return reading.accuracyMeters > 320 ? "confirm-area" : "review-place";
}
console.log(locationDecision({ timestamp: 47000, accuracyMeters: 420 }, 9000, 52000));
// Output: confirm-areaCost and tradeoffs
Processing each returned location is O(1), but a continuing watch creates repeated callbacks, battery use, and potential network writes over time. High accuracy can increase wait and energy cost while still failing indoors. A one-shot request reduces resource use, but its accuracy may be insufficient for a precise field operation. Choose based on the decision the user must make, not on the maximum precision the device can produce. Measure timeout, correction rate, number of active watches, and data retained per case.
Failure trace
An intake screen calls watchPosition for a single place label and never clears it. After the operator leaves, it keeps receiving positions and may write private movement data. Replace it with a one-shot request or clear the watch reliably. Another failure treats a location with a wide accuracy radius as an exact building. Display uncertainty and allow correction. Test denied permission, timeout, stale cache, late callbacks, account switch, and a device without location support. Confirm that deletion and export workflows include any stored coordinates under the chosen policy.
Decision note
Match location precision, duration, and storage to the actual field decision. A manual place is a valid outcome, and an accuracy radius is part of the data rather than an inconvenient detail to hide.
Verification
- Complete the primary case with the capability available and with it denied or absent.
- Interrupt the interaction during its pending state and confirm no stale resource, focus, or scroll state remains.
- Check that server authorization and validation still hold after the browser interaction.
Common Mistakes
- Using a continuous watch for a one-time place selection.
- Presenting approximate coordinates as a verified address.
- Retaining precise coordinates without a defined purpose.
Connected lessons
Browser Capabilities and Permission Lifecycle; Permission Request Timing and Manual Fallback; Camera and Microphone Capture and Track Cleanup; Clipboard and Share Activation Fallbacks; Offline and Device Capabilities; Browser Security and Data Stewardship; Retention Inventory and Expiry Workflows.
Apply and check
Build Project: field intake with capability fallbacks and review Web Development: browser capability and viewport decisions quiz.
Further connections
Geospatial Web Interfaces and Spatial Queries; Location Consent, Precision, and Map Alternatives.
