session.location to get the user’s GPS coordinates. You can read the cached position, subscribe to continuous updates, or request a fresh location fix.
Read Cached Location
The LocationManager caches the latest known position. Read it anytime:| Property | Type | Description |
|---|---|---|
session.location.lat | number | null | Latitude (null if no location received yet) |
session.location.lng | number | null | Longitude (null if no location received yet) |
session.location.accuracy | number | null | Accuracy in meters |
session.location.timestamp | number | null | Unix timestamp (ms) of the last update |
Subscribe to Updates
Get continuous location updates as the user moves:Request a Fresh Location
Request a one-shot location poll. The result arrives via youronUpdate listener:
accuracy parameter is optional (defaults to "standard").
Common Patterns
Show location on session start
Stop location updates
Stop all location tracking and clean up resources:onUpdate listeners and stops GPS polling. You can call onUpdate() again later to resume.
Location-aware content
Timezone from coordinates
Permissions
Your app needs the location permission to access GPS data. Add it in the Developer Console when creating or editing your app. Without location permission,session.location.hasPermission returns false, cached values stay null, and onUpdate receives no events.
Migrating from v2
getLatestLocation is available via the v2 compat shim during v3.0. The native v3 pattern is to read the cached lat/lng properties or use requestUpdate() + onUpdate(). See the Migration Guide for the full list of changes.
