Search This Blog

Sunday, 4 December 2016

LoctonEventRising

  private void showtheLocationDetails()
        {
            DependencyService.Get<IMyLocation>().ObtainMyLocation();
            DependencyService.Get<IMyLocation>().locationObtained += MainPage_locationObtained;
        }

        private async void MainPage_locationObtained(object sender, ILocationEventArgs e)
        {
            string strLatitute = e.lat.ToString();
            string strLongitute = e.lng.ToString();
            string locationUrl = "http://api.openweathermap.org/data/2.5/weather?lat="+ strLatitute +"&lon="+ strLongitute + "&appid=b631adf3653df30af9ce66a72cf9b6de";
            HttpClient objHttpClient = new HttpClient();
            var locationDetails =await objHttpClient.GetStringAsync(locationUrl);
            var Locations = JsonConvert.DeserializeObject<LocationModel>(locationDetails.ToString());

            lblSummaryLoction.Text = Locations.name;
            lblSummaryWeather.Text = (Locations.weather[0].description) +",," +(Locations.main.temp) + ",,"+(Locations.main.humidity) + (Locations.main.pressure);
            var ss = Locations;
        }

No comments:

Post a Comment