Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            List <Bus> busses;

            //create a HttpClient
            client             = new HttpClient();
            client.BaseAddress = new Uri("https://pribus.appbit.es/api/");
            mapUrl             = new MapUrl(47.5951518, -122.3316393);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            //get the buses' details as JSON
            response = client.GetAsync("v1/buses/").Result;
            result   = new StringBuilder(response.Content.ReadAsStringAsync().Result);
            //Deserlize the objects. Turn the JSON content to the appropriate c# objects

            list = JsonConvert.DeserializeObject <RootObject>(result.ToString());


            //Insert busses in the view list
            for (var i = 0; i < list.results.buses.Count; i++)
            {
                ListViewItem item = new ListViewItem(list.results.buses[i].line.name);
                listView1.Items.Insert(i, item);
            }

            mapUrl.displayMultipleMarkers(list);
            MessageBox.Show(mapUrl.completeUrlAddress);
            myBrowser.Load(mapUrl.completeUrlAddress);
        }