Пример #1
0
        /// <summary>
        /// Event handler for route query completed.
        /// </summary>
        /// <param name="e">Results of the geocode query - the route</param>
        private void RouteQuery_QueryCompleted(object sender, QueryCompletedEventArgs <Route> e)
        {
            HideProgressIndicator();
            if (e.Error == null)
            {
                MyRoute    = e.Result;
                MyMapRoute = new MapRoute(MyRoute);
                MyMap.AddRoute(MyMapRoute);

                // Update route information and directions
                DestinationText.Text = SearchTextBox.Text;
                double distanceInKm = (double)MyRoute.LengthInMeters / 1000;
                DestinationDetailsText.Text = distanceInKm.ToString("0.0") + " km, "
                                              + MyRoute.EstimatedDuration.Hours + " hrs "
                                              + MyRoute.EstimatedDuration.Minutes + " mins.";

                List <string> routeInstructions = new List <string>();
                foreach (RouteLeg leg in MyRoute.Legs)
                {
                    for (int i = 0; i < leg.Maneuvers.Count; i++)
                    {
                        RouteManeuver maneuver        = leg.Maneuvers[i];
                        string        instructionText = maneuver.InstructionText;
                        distanceInKm = 0;

                        if (i > 0)
                        {
                            distanceInKm     = (double)leg.Maneuvers[i - 1].LengthInMeters / 1000;
                            instructionText += " (" + distanceInKm.ToString("0.0") + " km)";
                        }
                        routeInstructions.Add(instructionText);
                    }
                }
                RouteLLS.ItemsSource = routeInstructions;

                AppBarDirectionsMenuItem.IsEnabled = true;

                if (_isDirectionsShown)
                {
                    // Center map on the starting point (phone location) and zoom quite close
                    MyMap.SetView(MyCoordinate, 16, MapAnimationKind.Parabolic);
                }
                else
                {
                    // Center map and zoom so that whole route is visible
                    MyMap.SetView(MyRoute.Legs[0].BoundingBox, MapAnimationKind.Parabolic);
                }
                MyRouteQuery.Dispose();
            }
            DrawMapMarkers();
        }
Пример #2
0
 void MyQuery_QueryCompleted(object sender, QueryCompletedEventArgs <Route> e)
 {
     if (e.Error == null)
     {
         try
         {
             Route    MyRoute    = e.Result;
             MapRoute MyMapRoute = new MapRoute(MyRoute);
             MyMap.AddRoute(MyMapRoute);
             MyQuery.Dispose();
         }
         catch
         {
         }
     }
 }
        private void MyQuery_QueryCompleted(object sender, QueryCompletedEventArgs <Route> e)
        {
            if (e.Error == null)
            {
                Route MyRoute = e.Result;
                if (MyMapRoute != null)
                {
                    //clear last route
                    MyMap.RemoveRoute(MyMapRoute);
                }
                MyMapRoute = new MapRoute(MyRoute);
                MyMap.AddRoute(MyMapRoute);
                MyQuery.Dispose();

                //set the map view to fit the route
                LocationRectangle locationRectangle = LocationRectangle.CreateBoundingRectangle(MyRoute.Geometry);
                this.MyMap.SetView(locationRectangle, new Thickness(10));
            }
        }
Пример #4
0
        private void QueryCompleted(object sender, QueryCompletedEventArgs <Route> e)
        {
            if (e.Error == null)
            {
                try
                {
                    Route MyRoute = e.Result;
                    MyMapRoute       = new MapRoute(MyRoute);
                    MyMapRoute.Color = CurrentColor;
                    MyMap.AddRoute(MyMapRoute);
                    Route.Text = "";

                    List <string> RouteList = new List <string>();
                    foreach (RouteLeg leg in MyRoute.Legs)
                    {
                        foreach (RouteManeuver maneuver in leg.Maneuvers)
                        {
                            RouteList.Add(maneuver.InstructionText);
                        }
                    }

                    foreach (string line in RouteList)
                    {
                        Route.Text += dot + ". " + line + '\n';
                        dot++;
                    }

                    calculate.Text    = "Find cycle";
                    calculate.IconUri = new Uri("/Images/dark.shuffle.png", UriKind.Relative);
                    start.Text        = "Find path";
                    start.IconUri     = new Uri("/Images/dark.map.treasure.png", UriKind.Relative);
                    EnableAppButtons(true);

                    MyQuery.Dispose();
                }
                catch (InvalidOperationException ex)
                {
                }
            }
        }