Geolocation


How to use the Geolocation class of the bit Butil?

Usage
To read the device's position you need to inject the Bit.Butil.Geolocation class and use it like this:
@inject Bit.Butil.Geolocation geolocation

@code {
    var position = await geolocation.GetCurrentPosition();
    await using var sub = await geolocation.SubscribeWatch(p => { /* ... */ });
}
Methods
The Geolocation class wraps the Geolocation API (navigator.geolocation).

IsSupported:
Returns whether the Geolocation API (navigator.geolocation) is available in the current browser (MDN).



GetCurrentPosition:
Returns the device's current position once. The browser prompts for permission on first use (MDN).



SubscribeWatch:
Subscribes to continuous position updates and returns a ButilSubscription handle. Dispose the handle to stop watching (MDN).