diff --git a/MyWeather/Services/WeatherService.cs b/MyWeather/Services/WeatherService.cs index e1e0354..ef1d467 100644 --- a/MyWeather/Services/WeatherService.cs +++ b/MyWeather/Services/WeatherService.cs @@ -2,6 +2,9 @@ using System.Net.Http; using System.Threading.Tasks; using static Newtonsoft.Json.JsonConvert; +using System; +using Plugin.Geolocator; +using System.Diagnostics; namespace MyWeather.Services { @@ -32,7 +35,18 @@ public async Task GetWeather(double latitude, double longitude, Uni } - public async Task GetWeather(string city, Units units = Units.Imperial) + public async Task GetWeatherGps (Units units = Units.Imperial) + { + var locator = CrossGeolocator.Current; + locator.DesiredAccuracy = 50; + + var position = await locator.GetPositionAsync (timeoutMilliseconds: 10000); + + return await GetWeather (position.Latitude, position.Longitude,units); + + } + + public async Task GetWeather(string city, Units units = Units.Imperial) { using (var client = new HttpClient()) {