BrowserLocationProvider

A browser location provider backed by the Geolocation API.

LocationAccuracy.BestForNavigation and LocationAccuracy.High set PositionOptions.enableHighAccuracy to true. The remaining accuracy values set it to false. The provider applies LocationRequest.minimumInterval after delivery. It ignores LocationRequest.minimumDistance because PositionOptions has no distance threshold.

A missing Geolocation API maps LocationProvider.backendAvailability to LocationBackendAvailability.Unsupported, and collection emits LocationUnavailableReason.Unsupported. GeolocationPositionError.PERMISSION_DENIED maps to LocationUnavailableReason.PermissionDenied. POSITION_UNAVAILABLE and TIMEOUT map to LocationUnavailableReason.TemporarilyUnavailable. An exception thrown while starting the live watch maps to LocationUnavailableReason.UnexpectedFailure.

LocationProvider.permission and LocationProvider.requestPermission delegate to a BrowserLocationPermissionRequester that shares the provider's boundary, so a permission denial during an active watch updates LocationProvider.permission.

Constructors

Link copied to clipboard
constructor()

Creates a provider that observes permission in a coroutine scope that lives as long as the provider.

constructor(coroutineScope: CoroutineScope)

Creates a provider that observes permission in coroutineScope.

Properties

Link copied to clipboard

Whether this provider has a usable platform implementation.

Link copied to clipboard
open val backendId: String?

A stable implementation name for diagnostics, when the provider declares one.

Link copied to clipboard
open override val permission: StateFlow<LocationPermission>

Current foreground location permission.

Functions

Link copied to clipboard
open override fun requestPermission()

Starts a foreground permission request and returns immediately.

Link copied to clipboard
open override fun updates(request: LocationRequest): Flow<LocationEvent>

Returns a cold stream of foreground location updates.