private void updateMap(PlacesList aWiKIAPIResponse) { int totalRecords = aWiKIAPIResponse.PlaceList.Count(); mapControl.CredentialsProvider = new ApplicationIdCredentialsProvider(AppConstants.strBingMapCredentialKey); mapControl.Visibility = System.Windows.Visibility.Visible; mapControl.ZoomLevel = 10; mapControl.ZoomBarVisibility = Visibility.Visible; try { for (int index = 0; index < totalRecords; index++) { double latitude = Convert.ToDouble(aWiKIAPIResponse.PlaceList[index].Latitude, CultureInfo.InvariantCulture); double longitude = Convert.ToDouble(aWiKIAPIResponse.PlaceList[index].Longitude, CultureInfo.InvariantCulture); mapControl.Center = new GeoCoordinate(latitude, longitude); Pushpin pushpinObj = new Pushpin(); pushpinObj.Content = aWiKIAPIResponse.PlaceList[index].Title + "\n" + aWiKIAPIResponse.PlaceList[index].Feature; pushpinObj.Background = new SolidColorBrush(Colors.Red); pushpinObj.Location = mapControl.Center; pushpinObj.Opacity = 0.5; mapControl.Children.Add(pushpinObj); } } catch (Exception) { } }
public async Task <PlacesList> GetListPlaces() { using (HttpClient client = new HttpClient()) { try { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "https://td-api.julienmialon.com/places"); HttpResponseMessage response = await client.SendAsync(request); var jsonString = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { var contentResponse = await response.Content.ReadAsStringAsync(); Response <List <PlaceItemSummary> > res = JsonConvert.DeserializeObject <Response <List <PlaceItemSummary> > >(contentResponse); PlacesList list = new PlacesList(res.Data); Barrel.Current.Add(key: "PlacesList", data: list, expireIn: TimeSpan.FromDays(1)); return(new PlacesList(res.Data)); } else { Console.WriteLine("Code error"); return(null); } } catch (HttpRequestException e) { Console.WriteLine(e.Message); return(null); } } }
public void Setup(PlacesList place) { Title.text = char.ToUpper(place.Name[0]) + place.Name.Substring(1); Description.text = place.Description; Category.text = "Mountains"; StartCoroutine(LoadImage(place.ThumbnailUrl, texture => { Thumbnail.texture = texture; })); }
private void parseResponseData(String aResponse) { placesListObj = new PlacesList(); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(aResponse)); DataContractJsonSerializer ser = new DataContractJsonSerializer(placesListObj.GetType()); placesListObj = ser.ReadObject(ms) as PlacesList; ms.Close(); // updating UI if (placesListObj != null) { updateMap(placesListObj); } }
public PlacesListPage(RootPage root) { InitializeComponent(); var vm = new HomeViewModel(Navigation); BindingContext = vm; this.root = root; Title = "PlacesList"; PlacesList.IsPullToRefreshEnabled = true; PlacesList.RefreshCommand = vm.RefreshCommand; PlacesList.SetBinding(ListView.IsRefreshingProperty, nameof(HomeViewModel.IsBusy)); PlacesList.ItemTapped += PlacesList_ItemTapped; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); _adapter = Vm.Places.GetRecyclerAdapter( BindViewHolder, Resource.Layout.PlaceTemplate, OnItemClick); _bindings.Add(this.SetBinding( () => Vm.Loading, () => RefreshLayout.Refreshing)); PlacesList.SetLayoutManager(new LinearLayoutManager(this)); PlacesList.SetAdapter(_adapter); RefreshLayout.SetColorSchemeColors(Color.Red, Color.Yellow, Color.Green); RefreshLayout.Refresh += RefreshLayoutOnRefresh; }