Пример #1
0
        private static MemoryLayer GetPathLayer(Route route)
        {
            var layer = new PathLayer(route.Waypoints, "route")
            {
                Style = new StyleCollection()
                {
                    new VectorStyle // Gray outer
                    {
                        Enabled = true,
                        Line    = new Pen(Color.FromArgb(255, 120, 120, 120))
                        {
                            PenStyle = PenStyle.Solid, Width = 12d
                        }
                    },
                    new VectorStyle // Blue inner
                    {
                        Enabled = true,
                        Line    = new Pen(Color.FromArgb(255, 100, 149, 237))
                        {
                            PenStyle = PenStyle.Solid, Width = 6d
                        }
                    }
                }
            };

            layer.Style.Enabled = true;
            return(layer);
        }
Пример #2
0
 public void RemoveFromLayer()
 {
     if (PathLayer != null)
     {
         PathLayer.RemoveObject(this);
     }
 }
Пример #3
0
 public PathFinder(Map Map)
 {
     this.Map      = Map;
     WayPointLayer = new PathLayer(Map.TabMap);
 }
Пример #4
0
        protected override async void OnAppearing()
        {
            if (Navigator != null)
            {
                return;
            }

            await Application.Current.MainPage.Navigation.PushModalAsync(new LookingForGpsPage());

            Route route = null;

            try
            {
                route = await _routeTask;
            } catch (Exception e)
            {
                var properties = new Dictionary <string, string>
                {
                    { "Category", "Route parsing" }
                };
                Crashes.TrackError(e, properties);

                return;
            }

            try
            {
                MapView.Info += async(sender, args) =>
                {
                    args.Handled = true;
                    if (args.MapInfo.Feature is PointOfInterestFeature poif)
                    {
                        await poif.OnClick();
                    }
                };

                var routeLayer = new PathLayer(
                    route.GetEnumerable(route.Waypoints.First(), Direction.Forward),
                    Consts.MainPathLayerName
                    );
                routeLayer.Style = null;
                routeLayer.feature.Styles.Add(
                    new VectorStyle()
                {
                    Line = new Pen(Color.FromArgb(255, 48, 78, 130))
                    {
                        PenStyle = PenStyle.Solid,
                        Width    = 15d
                    }
                }
                    );
                routeLayer.feature.Styles.Add(
                    new VectorStyle()
                {
                    Line = new Pen(Color.FromArgb(255, 45, 115, 200))
                    {
                        PenStyle = PenStyle.Solid,
                        Width    = 12d
                    }
                }
                    );

                MapView.Map.Layers.Add(routeLayer);
            } catch (Exception e)
            {
                var properties = new Dictionary <string, string>
                {
                    { "Category", "Map styling" }
                };
                Crashes.TrackError(e, properties);

                return;
            }

            try
            {
                NavigationStats = new NavigationStats(route);
                Navigator       = new Navigator(MapView, route, CrossGeolocator.Current, NavigationStats);

                DistanceLabel.SetBinding(Label.TextProperty, new Binding("Progress", source: NavigationStats));

                if (await Navigator.StartNavigation())
                {
                    await Application.Current.MainPage.Navigation.PopModalAsync();
                }
            } catch (Exception e)
            {
                var properties = new Dictionary <string, string>
                {
                    { "Category", "Navigation" }
                };
                Crashes.TrackError(e, properties);

                return;
            }
        }