Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 //On each of the items in the view list the below event is set. Once the item is selected, based on the bus it represents it will show its position in the map
 private void ListView1_ItemActivate(object sender, EventArgs e)
 {
     getJson();
     index  = listView1.SelectedItems[0].Index;
     mapUrl = new MapUrl(Double.Parse(list.results.buses[index].latitude), Double.Parse(list.results.buses[index].longitude));
     myBrowser.Load(mapUrl.completeUrlAddress);
     timer1.Start();
 }
Ejemplo n.º 3
0
 private void BtnSearch_Click(object sender, EventArgs e)
 {
     searchedPlace = txtSearch.Text;
     //mapUrl = new MapUrl(searchedPlace);
     mapUrl = new MapUrl(47.5951518, -122.3316393);
     // webBrowser1.Navigate(new Uri(mapUrl.completeUrlAddress));
     myBrowser.Refresh();
 }
Ejemplo n.º 4
0
 //This timer will update the current bus location shown in the map
 private void Timer1_Tick(object sender, EventArgs e)
 {
     getJson();
     mapUrl = new MapUrl(Double.Parse(list.results.buses[index].latitude), Double.Parse(list.results.buses[index].longitude));
     myBrowser.Load(mapUrl.completeUrlAddress);
 }