I would like to have the option of getting the current user location on my blazor (server) app. I had tried to use two solutions Darnton.Blazor.DeviceInterop and AspNetMonsters.Blazor.Geolocation. With the first one, I had a problem with how to properly use that, the second one after NuGet install break the whole application ... I will be grateful for sharing other solutions, the simpler the better
If you install the Blazor Geolocation package you mentioned (Darnton.Blazor.DeviceInterop), you should be able to use the GeolocationService with a one-liner:
CurrentPositionResult = await GeolocationService.GetCurrentPosition();
I've written it all up in more detail if you want to understand what's going on inside:
https://darnton.co.nz/2020/11/29/geolocation-in-blazor/
https://darnton.co.nz/2020/11/30/geolocation-ii-position-updates/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With