예제 #1
0
        public async Task IpApiComExample()
        {
            IpApiCom.Response response = await IpApiCom.GetResponse();

            Log.d("Your IP is " + response.query);
            Log.d("The name of your city is " + response.city);
            Assert.NotEmpty(response.query);
            Assert.NotEmpty(response.@as);
        }
예제 #2
0
        public async Task MetaWeatherComExample1()
        {
            var ipLookupResult = await IpApiCom.GetResponse();

            string yourCity         = ipLookupResult.city;
            var    cityLookupResult = await MetaWeatherLocationLookup.GetLocation(yourCity);

            if (cityLookupResult.IsNullOrEmpty())
            {
                cityLookupResult = await MetaWeatherLocationLookup.GetLocation((float)ipLookupResult.lat, (float)ipLookupResult.lon);
            }
            Assert.False(cityLookupResult.IsNullOrEmpty(), "Did not find any location for city=" + yourCity);
            int whereOnEarthIDOfYourCity = cityLookupResult.First().woeid;
            var report = await MetaWeatherReport.GetReport(whereOnEarthIDOfYourCity);

            Log.d("Full weather report: " + JsonWriter.AsPrettyString(report));
            var currentWeather = report.consolidated_weather.Map(r => r.weather_state_name);

            Log.d("The weather today in " + yourCity + " is: " + currentWeather.ToStringV2());
        }