Skip to content

Commit

Permalink
Added GetWeatherGps method to the Service
Browse files Browse the repository at this point in the history
  • Loading branch information
Clancey committed Aug 4, 2016
1 parent bf25865 commit 226335d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion MyWeather/Services/WeatherService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -32,7 +35,18 @@ public async Task<WeatherRoot> GetWeather(double latitude, double longitude, Uni

}

public async Task<WeatherRoot> GetWeather(string city, Units units = Units.Imperial)
public async Task<WeatherRoot> 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<WeatherRoot> GetWeather(string city, Units units = Units.Imperial)
{
using (var client = new HttpClient())
{
Expand Down

0 comments on commit 226335d

Please sign in to comment.