What is the difference between Geolocation.Default.GetLocationAsync()
and Geolocation.GetLocationAsync()
?
I have tried both and I don't see the difference.
They all can return the current location of the device. However, the Geolocation.Default
provides the default implementation for static usage of this API:
public static Microsoft.Maui.Devices.Sensors.IGeolocation Default { get; }
That said, if you are using the GetLocationAsync()
in MAUI, it's recommended to use Geolocation.Default.GetLocationAsync()
.
For more information, you can refer to the links below:
https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/device/geolocation?tabs=android