/// <summary> /// register a handler function that will be called automatically each time the position of the device changes. /// </summary> /// <param name="callback"></param> /// <param name="options"></param> /// <returns></returns> public async ValueTask <IAsyncDisposable> WatchPosition(Func <GeolocationResult, ValueTask> callback, PositionOptions options = null) { var wrapper = new WatchGeolocationWrapper(callback, jsRuntime); var watchId = await jsRuntime.InvokeAsync <int>( "browserInterop.navigator.geolocation.watchPosition", options, DotNetObjectReference.Create(wrapper)).ConfigureAwait(false); wrapper.SetWatchId(watchId); return(wrapper); }
/// <summary> /// used to get the current position of the device. /// </summary> /// <param name="options"></param> /// <returns></returns> public async ValueTask <GeolocationResult> GetCurrentPosition(PositionOptions options = null) { return(await jsRuntime.InvokeAsync <GeolocationResult>( "browserInterop.navigator.geolocation.getCurrentPosition", options).ConfigureAwait(false)); }