private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { Header.Text = "Loading."; var statsDataGroups = await StatsDataSource.GetGroupsAsync(); DefaultViewModel["Groups"] = statsDataGroups; Header.Text = "Statistics"; }
private async Task GetLocalData() { Backdrop.Fill = new SolidColorBrush(Colors.DarkRed); TextBlock.Text = "Something went wrong..."; Bikeimage.Visibility = Visibility.Collapsed; ProgressRing.Visibility = Visibility.Visible; TextBlock.Visibility = Visibility.Visible; Backdrop.Visibility = Visibility.Visible; ProgressRing.IsActive = true; var temp = new ObservableCollection <CollectedDataGroup>(); var statsDataGroups = await StatsDataSource.GetGroupsAsync(); BikeDataGroups = await BikePointDataSource.GetLocalGroupsAsync(); foreach (var item in BikeDataGroups) { temp.Add(new CollectedDataGroup( item.CommonName, item.Id, item.Lat, item.Lon, item.Url, item.AdditionalProperties[0].Value, item.AdditionalProperties[1].Value, item.AdditionalProperties[2].Value, item.AdditionalProperties[3].Value, item.AdditionalProperties[4].Value, item.AdditionalProperties[5].Value, item.AdditionalProperties[6].Value, item.AdditionalProperties[7].Value, item.AdditionalProperties[8].Value)); var pushpin = new Pushpin() { Background = new SolidColorBrush(Colors.DodgerBlue), }; MapLayer.SetPosition(pushpin, new Location(item.Lat, item.Lon)); _bikeMap.Children.Add(pushpin); pushpin.Tapped += BikePointPin_Tapped; pushpin.PointerEntered += BikePointPin_PointerEntered; pushpin.PointerExited += BikePointPin_PointerExited; } CacheDataCollection.Add(temp); BikeDataCollection.Add(temp); //Set map location try { TextBlock.Text = "Getting your location."; var geolocator = new Geolocator(); var geoposition = await geolocator.GetGeopositionAsync(); if (geoposition != null) { _bikeMap.SetView(new Location(geoposition.Coordinate.Point.Position.Latitude, geoposition.Coordinate.Point.Position.Longitude), 18, TimeSpan.FromSeconds(3)); MapLayer.SetPosition(_selfpushpin, new Location(geoposition.Coordinate.Point.Position.Latitude, geoposition.Coordinate.Point.Position.Longitude)); _bikeMap.Children.Remove(_selfpushpin); _bikeMap.Children.Add(_selfpushpin); } } catch (Exception) { _bikeMap.SetView(new Location(51.5072, 0.1275), 15); } ProgressRing.Visibility = Visibility.Collapsed; TextBlock.Visibility = Visibility.Collapsed; Backdrop.Visibility = Visibility.Collapsed; ProgressRing.IsActive = false; ProgressRing.IsActive = false; ViewModel["Costs"] = statsDataGroups; ViewModel["BikesShort"] = BikeDataCollection; }