public async void GetCurrentLocation() { await MyLocalization.GetCurrentLocation(); latitude = MyLocalization.latitude; longitude = MyLocalization.longitude; }
public async void GetTemperature() { await MyLocalization.GetCurrentLocation(); Latitude = MyLocalization.latitude; Longitude = MyLocalization.longitude; if (!useGPS) { Latitude = 40.416775; Longitude = -3.703790; } var url = "/data/2.5/forecast/daily?lat=" + Latitude + "&lon=" + Longitude + "&cnt=5&units=" + units + "&appid=" + apiKey; forecast = await apiService.GetForecast(url); if (apiService.SuccessConnection) { Temperature = Math.Round(forecast.list[0].temp.day); Description = forecast.list[0].weather[0].main; City = forecast.city.name.ToUpper(); CountryCode = forecast.city.country; Humidity = forecast.list[0].humidity + "%"; var windAux = 0.0; windAux = (forecast.list[0].speed * 60 * 60) / 1000; Wind = string.Format("{0:0.00}", windAux); Wind += " km/h"; Clouds = forecast.list[0].clouds + "%"; Pressure = forecast.list[0].pressure.ToString(); Pressure = Pressure.Substring(0, 4) + " pHa"; CurrentCondition = forecast.list[0].weather[0].description; CurrentCondition = char.ToUpper(CurrentCondition[0]) + CurrentCondition.Substring(1); CurrentRange = forecast.list[0].temp.max + "º / " + forecast.list[0].temp.min + "º"; GetCountryName(); AddForecast(); } if (Latitude == 0 && Longitude == 0) { { await Application.Current.MainPage.DisplayAlert("Error", "Can't access to GPS", "Accept"); } } }