using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Justice.Helpers { public class GeolocationHelper { public static async Task<(double Latitude, double Longitude)> GetCurrentLocationAsync() { var location = await Geolocation.Default.GetLocationAsync(); if (location != null) { return (location.Latitude, location.Longitude); } throw new Exception("Unable to fetch location"); } public static async Task GetReadableAddressAsync(double latitude, double longitude) { var placemarks = await Geocoding.Default.GetPlacemarksAsync(latitude, longitude); var placemark = placemarks.FirstOrDefault(); if ( placemark !=null) { return $"{placemark.SubLocality}, {placemark.Thoroughfare}, {placemark.Locality}, {placemark.CountryName}"; } return "Address Not Found"; } } }