Ejemplo n.º 1
0
        public async void GetWeatherData()
        {
            var geoposition = await LocationManager.GetGeopositionAsync();

            var currentLocationKey = await WeatherAPI.GetCityDstaAsync(geoposition.Coordinate.Point.Position.Latitude, geoposition.Coordinate.Point.Position.Longitude);

            var weatherData = await WeatherAPI.GetWeatherAsync(currentLocationKey.Key);

            if (weatherData != null)
            {
                foreach (var item in weatherData.DailyForecasts)
                {
                    DailyForecasts.Add(item);
                }
            }
            Ring       = false;
            CurrentDay = DailyForecasts[0];
        }
Ejemplo n.º 2
0
        public static async Task <string> GetCityData()
        {
            var citydata = await LocationManager.GetGeopositionAsync();

            BasicGeoposition geoposition = new BasicGeoposition()
            {
                Latitude = citydata.Coordinate.Point.Position.Latitude, Longitude = citydata.Coordinate.Point.Position.Longitude
            };
            Geopoint geopoint = new Geopoint(geoposition);

            MapService.ServiceToken = KEY;

            MapLocationFinderResult finderResult = await MapLocationFinder.FindLocationsAtAsync(geopoint);

            if (finderResult.Status != MapLocationFinderStatus.Success)
            {
                return(null);
            }

            return(finderResult.Locations[0].Address.Town);
        }