Ejemplo n.º 1
0
 private void OnShowRouteDetails(Route route)
 {
     _data.SelectedRoute.Value = route;
     _navigationService.Navigate<RouteDetailsViewModel>();
 }
Ejemplo n.º 2
0
        public static Route ToLocalRoute(this Codify.GoogleMaps.Entities.Route route)
        {
            if (route == null) throw new ArgumentNullException("route", "Cannot convert null Codify.GoogleMaps.Entities.Route to local Travlexer.Data.Route.");
            var newRoute = new Route();

            var legs = route.Legs;
            if (!legs.IsNullOrEmpty())
            {
                var leg = legs[0];
                newRoute.Distance = leg.Distance.Value;
                newRoute.Duration = leg.Duration.Value;

                var steps = leg.Steps;
                if (!steps.IsNullOrEmpty())
                {
                    var points = new Collection<Location>();
                    var routeSteps = new Collection<RouteStep>();
                    foreach (var step in steps)
                    {
                        points.AddRange(Utilities.DecodePolylinePoints(step.Polyline.Points));
                        routeSteps.Add(new RouteStep
                        {
                            Distance = step.Distance.Value,
                            Duration = step.Duration.Value,
                            Instruction = XmlTagRegex.Replace(DivTagRegex.Replace(step.HtmlInstructions, Environment.NewLine), string.Empty),
                            StartLocation = step.StartLocation.ToLocalLocation(),
                            EndLocation = step.EndLocation.ToLocalLocation()
                        });
                    }
                    newRoute.Points = points;
                    newRoute.Steps = routeSteps;
                }
            }

            return newRoute;
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Sets the map view to the optimal position for the specified route.
 /// </summary>
 /// <param name="route">The route.</param>
 private void SetViewForRoute(Route route)
 {
     var locations = route.Points;
     var coordinates = locations.Select(l => l.ToGeoCoordinate()).ToArray();
     if (!coordinates.Any())
     {
         return;
     }
     Map.SetView(LocationRect.CreateLocationRect(coordinates));
 }
Ejemplo n.º 4
0
 public bool Equals(Route other)
 {
     if (ReferenceEquals(null, other))
     {
         return false;
     }
     if (ReferenceEquals(this, other))
     {
         return true;
     }
     int pointCount;
     return other.Method == Method
            && other.Mode == Mode
            && other.Points != null
            && Points != null
            && other.Points.Count == (pointCount = Points.Count)
            && other.Points[0] == Points[0]
            && other.Points[--pointCount] == Points[pointCount];
 }