コード例 #1
0
        private string GenerateRequestUriWithLatLon(string endpoint, Location location)
        {
            string lat        = location.lat.ToString();
            string lon        = location.lon.ToString();
            var    requestUri = endpoint;

            requestUri += $"?lat={lat}&lon={lon}";
            requestUri += "&units=metric";
            requestUri += $"&APPID={API_Data.OpenWeatherMapAPIKey}";
            return(requestUri);
        }
コード例 #2
0
        public async Task ShowCurrentWeatherAsync()
        {
            Location loc = GetCurrentLocation();

            currentweather = await GetWeatherWithLatLonAsync(loc);

            area = await GetCurrentArea(loc);

            SetWeather();

            OnPropertyChanged("area");
        }
コード例 #3
0
        public async Task <WeatherData> GetWeatherWithLatLonAsync(Location location)
        {
            IsLoading = true;
            OnPropertyChanged("IsLoading");

            currentweather = await restservice.GetWeatherData(GenerateRequestUriWithLatLon(API_Data.OpenWeatherMapEndpoint, location));



            if (currentweather != null)
            {
                return(currentweather);
            }
            else
            {
                throw (new ArgumentNullException());
            }
        }
コード例 #4
0
 private async Task <string> GetCurrentArea(Location loc)
 {
     return(await restservice.ResolveAreaAsync(loc));
 }