protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_mock_navigation);
            Cheeseknife.Bind(this);
            routeRefresh = new RouteRefresh(Mapbox.Mapboxsdk.Mapbox.AccessToken, this);

            mapView.OnCreate(savedInstanceState);
            mapView.GetMapAsync(this);

            Context context = ApplicationContext;
            CustomNavigationNotification customNotification = new CustomNavigationNotification(context);
            MapboxNavigationOptions      options            = MapboxNavigationOptions.InvokeBuilder()
                                                              .NavigationNotification(customNotification)
                                                              .Build();

            navigation = new Mapbox.Services.Android.Navigation.V5.Navigation.MapboxNavigation(this, Mapbox.Mapboxsdk.Mapbox.AccessToken, options);

            var builder = new RouteMilestone.Builder();

            builder.SetIdentifier(BEGIN_ROUTE_MILESTONE);
            builder.SetInstruction(new BeginRouteInstruction());
            builder.SetTrigger(
                Trigger.All(
                    Trigger.Lt(TriggerProperty.StepIndex, 3),
                    Trigger.Gt(TriggerProperty.StepDistanceTotalMeters, 200),
                    Trigger.Gte(TriggerProperty.StepDistanceTraveledMeters, 75)
                    )
                );

            navigation.AddMilestone(builder.Build());
            customNotification.Register(new MyBroadcastReceiver(navigation), context);
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_mock_navigation);

            mapView          = FindViewById <MapView>(Resource.Id.mapView);
            newLocationFab   = FindViewById <FloatingActionButton>(Resource.Id.newLocationFab);
            startRouteButton = FindViewById <Button>(Resource.Id.startRouteButton);

            newLocationFab.Click   += OnNewLocationClick;
            startRouteButton.Click += OnStartRouteClick;

            mapView.OnCreate(savedInstanceState);
            mapView.GetMapAsync(this);

            navigation = new MapboxNavigation(this, Mapbox.AccessToken);

            navigation.AddMilestone(new RouteMilestone.Builder()
                                    .SetIdentifier(BEGIN_ROUTE_MILESTONE)
                                    .SetInstruction(new BeginRouteInstruction())
                                    .SetTrigger(
                                        Trigger.All(
                                            Trigger.Lt(TriggerProperty.StepIndex, 3),
                                            Trigger.Gt(TriggerProperty.StepDistanceTotalMeters, 200),
                                            Trigger.Gte(TriggerProperty.StepDistanceTraveledMeters, 75)
                                            )
                                        ).Build());
        }