Near me triggers geolocation API with graceful fallback on denial
Why it matters
A "near me" feature that crashes or silently fails when location permission is denied provides no usable fallback and locks out users who decline location sharing — a growing segment due to increased browser permission fatigue. ISO 25010:2011 reliability requires that systems handle expected failure conditions gracefully. From a product standpoint, permission denial is not an error state; it is a normal user choice. A crash or blank screen on denial destroys trust at exactly the moment a user is evaluating whether to engage with your directory. The feature is marked critical because it gates the primary location-based use case of the entire product.
Severity rationale
Critical because geolocation permission denial is a normal, expected user action — an app crash or silent failure at this point is a primary-flow breakage that blocks location-based search entirely.
Remediation
Handle all three geolocation error codes explicitly and offer an address input fallback immediately on denial. Do not rely on the browser's default error dialog.
function NearMeButton() {
const [error, setError] = useState<string | null>(null);
const [showAddressInput, setShowAddressInput] = useState(false);
const handleNearMe = () => {
if (!navigator.geolocation) {
setError('Your browser does not support location detection.');
setShowAddressInput(true);
return;
}
navigator.geolocation.getCurrentPosition(
(pos) => searchListings(pos.coords.latitude, pos.coords.longitude),
(err) => {
const messages: Record<number, string> = {
1: 'Location access denied. Enter a zip code or address instead.',
2: 'Location unavailable. Enter a zip code or address instead.',
3: 'Location request timed out. Enter a zip code or address instead.',
};
setError(messages[err.code] ?? 'Could not detect location.');
setShowAddressInput(true);
},
{ timeout: 8000 }
);
};
return (
<>
<button onClick={handleNearMe}>Find Nearby</button>
{error && <p role="alert">{error}</p>}
{showAddressInput && <AddressFallbackInput onSubmit={searchListings} />}
</>
);
}
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Map & Location Integration Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · reliability — Fault Tolerance — graceful fallback when Geolocation API is denied or unavailable
Taxons
History
- 2026-04-18·v1.0.0·Initial import from directory-map-location·automated