.NET MAUI › Device Features & Essentials

How do you get the device's geolocation in MAUI?

Beginner

Answer

Use Geolocation.Default.GetLocationAsync (last-known or a fresh request with GeolocationRequest specifying accuracy and timeout). Request location permission first. GetLastKnownLocationAsync is faster but may be stale; GetLocationAsync forces a fix.
var request = new GeolocationRequest(GeolocationAccuracy.Medium,
    TimeSpan.FromSeconds(10));
var loc = await Geolocation.Default.GetLocationAsync(request);
Real-world example A weather app fetches the user's coordinates to show local conditions after requesting location permission.

Common follow-ups: Last-known vs fresh location? | What permission is required?