Browse Source

Added map usabilty without waypoints & route
Fixed route and waypoint delay/missing

Jeroen 10 years ago
parent
commit
cf0d45b9cf

+ 25 - 19
Breda-Tour/MapScreen/MapPage.xaml.cs

@@ -24,6 +24,7 @@ using Windows.UI.Xaml.Shapes;
 using Breda_Tour.CustomControls;
 using System.Diagnostics;
 using Breda_Tour.Data;
+using Breda_Tour.RouteSelectScreen;
 
 // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
 
@@ -54,9 +55,12 @@ namespace Breda_Tour.MapScreen
         {
             SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
             DefaultPivot.SetCheckedButton(DefaultPivotControl.Tab.Map);
-            if (this.route == null)
+            if (RouteExample.fromRouteExamp)
             {
+                RouteExample.fromRouteExamp = false;
                 route = e.Parameter as Route;
+                ShowWaypoints(route);
+                ShowRoute();
             }
         }
 
@@ -73,28 +77,30 @@ namespace Breda_Tour.MapScreen
                marker.Location = point;
            });
             await Map.TrySetViewAsync(point, 17);
-            ShowWaypoints(route);
-            ShowRoute(route);
         }
 
-        public async void ShowRoute(Route route)
+        public async void ShowRoute()
         {
-            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
+            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             {
-                List<Geopoint> geopoints = new List<Geopoint>();
-                foreach (Waypoint wayPoint in route.Waypoints)
-                {
-                    geopoints.Add(wayPoint.Position);
-                }
-                MapRouteFinderResult finder = await MapRouteFinder.GetWalkingRouteFromWaypointsAsync(geopoints);
-                if (finder.Status == MapRouteFinderStatus.Success)
-                {
-                    MapRouteView routeView = new MapRouteView(finder.Route);
-                    routeView.RouteColor = Colors.Firebrick;
-                    routeView.OutlineColor = Colors.Black;
-                    Map.Routes.Add(routeView);
-                }
+                Map.Routes.Add(RouteExample.routeView);
             });
+            //await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
+            //{
+            //    List<Geopoint> geopoints = new List<Geopoint>();
+            //    foreach (Waypoint wayPoint in route.Waypoints)
+            //    {
+            //        geopoints.Add(wayPoint.Position);
+            //    }
+            //    MapRouteFinderResult finder = await MapRouteFinder.GetWalkingRouteFromWaypointsAsync(geopoints);
+            //    if (finder.Status == MapRouteFinderStatus.Success)
+            //    {
+            //        MapRouteView routeView = new MapRouteView(finder.Route);
+            //        routeView.RouteColor = Colors.Firebrick;
+            //        routeView.OutlineColor = Colors.Black;
+            //        Map.Routes.Add(routeView);
+            //    }
+            //});
         }
 
         public async void ShowWaypoints(Route route)
@@ -124,7 +130,7 @@ namespace Breda_Tour.MapScreen
                 {
                     if (x + 1 == int.Parse(Icon.Title))
                     {
-                        MainPage.RootFrame.Navigate(typeof (WpDetailPage), route.Waypoints.ElementAt(x));
+                        MainPage.RootFrame.Navigate(typeof(WpDetailPage), route.Waypoints.ElementAt(x));
                     }
                 }
             }

+ 7 - 0
Breda-Tour/RouteSelectScreen/RouteExample.xaml.cs

@@ -34,6 +34,8 @@ namespace Breda_Tour.RouteSelectScreen
         public string WaypointsText { get; set; }
         public string RouteTijdText { get; set; }
         public string LoopafstandText { get; set; }
+        public static bool fromRouteExamp;
+        public static MapRouteView routeView;
 
         public RouteExample()
         {
@@ -63,6 +65,7 @@ namespace Breda_Tour.RouteSelectScreen
 
         private void Button_Click(object sender, RoutedEventArgs e)
         {
+            fromRouteExamp = true;
             MainPage.RootFrame.Navigate(typeof(MapPage), route);
         }
 
@@ -83,6 +86,10 @@ namespace Breda_Tour.RouteSelectScreen
             MapRouteFinderResult finder = await MapRouteFinder.GetWalkingRouteFromWaypointsAsync(geopoints);
             if (finder.Status == MapRouteFinderStatus.Success)
             {
+                //Create route for mapPage
+                routeView = new MapRouteView(finder.Route);
+                routeView.RouteColor = Colors.Firebrick;
+                routeView.OutlineColor = Colors.Black;
                 //route duration
                 int tijd = ((int)finder.Route.EstimatedDuration.TotalMinutes);
                 RouteTijdText = $"Tijdsduur: {tijd} min";