public async Task <List <PlaceEntity> > getPlaces(CategoriesContainer categoriesContainer) { string requestString = "active=true&future=true"; if (categoriesContainer != null) { requestString = "active=" + categoriesContainer.time["current"].ToString() + "&future=" + categoriesContainer.time["future"].ToString(); } else { categoriesContainer = new CategoriesContainer() { categories = await getCategoriesDict() }; } List <Domain.PlaceEntity> list = await fetchObject <List <Domain.PlaceEntity> >(@"/place/filter?" + requestString, "POST", categoriesContainer.categories); if (list == null) { list = new List <Domain.PlaceEntity>(); } return(list); }
public void ApplyFilters() { CategoriesContainer container = new CategoriesContainer() { categories = categoryToggled, time = timeToggled }; page.Frame.Navigate(typeof(MapPage), container); }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { // TODO: Prepare page for display here. // TODO: If your application contains multiple pages, ensure that you are // handling the hardware Back button by registering for the // Windows.Phone.UI.Input.HardwareButtons.BackPressed event. // If you are using the NavigationHelper provided by some templates, // this event is handled for you. categoriesContainer = (CategoriesContainer)e.Parameter; }
public async Task MapLoaded(CategoriesContainer categoriesContainer) { page.Map.ZoomLevel = 5; ServiceRepository serviceRepository = new ServiceRepository(); List <PlaceEntity> places = await serviceRepository.getPlaces(categoriesContainer); if (places.Count == 0) { return; } // calculate center of all places GeoCoordinate centerCoordinate = new GeoCoordinate(0, 0); foreach (PlaceEntity place in places) { centerCoordinate.Latitude += place.Location.Latitude; centerCoordinate.Longitude += place.Location.Longitude; var geopoint = new Geopoint ( new BasicGeoposition() { Latitude = place.Location.Latitude, Longitude = place.Location.Longitude } ); StackPanel pin = new StackPanel(); Image pinImage = new Image { Width = 64, Height = 64, Source = new BitmapImage(new Uri("ms-appx:///Assets/PlaceIcon.png")), }; TextBlock pinText = new TextBlock { Text = place.Name, TextWrapping = TextWrapping.NoWrap, FontSize = 20, Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)) }; pin.Tapped += new TappedEventHandler(delegate(object sender, TappedRoutedEventArgs e) { page.Frame.Navigate(typeof(InformationListPage), place); } ); pin.Children.Add(pinImage); pin.Children.Add(pinText); // Add XAML to the map. page.Map.Children.Add(pin); MapControl.SetLocation(pin, geopoint); MapControl.SetNormalizedAnchorPoint(pin, new Point(0.5, 0.5)); } centerCoordinate.Latitude /= places.Count; centerCoordinate.Longitude /= places.Count; var center = new Geopoint ( new BasicGeoposition() { Latitude = centerCoordinate.Latitude, Longitude = centerCoordinate.Longitude } ); // retrieve map await page.Map.TrySetViewAsync(center); }