コード例 #1
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());
        }
コード例 #2
0
        private async void BuildingRouteAsync()
        {
            var             id      = Intent.GetStringExtra(IDPED);
            string          sql     = string.Format("Select * From TapFood.Pedido Where(IdPedido='{0}') Limit 1", id);
            MySqlCommand    command = new MySqlCommand(sql, conn);
            MySqlDataReader reader;

            reader = command.ExecuteReader();
            reader.Read();
            double latusr = (double)reader["LatitudUsuario"];
            double lngusr = (double)reader["LongitudUsuario"];
            double latrep = (double)reader["LatitudRepartidor"];
            double lngrep = (double)reader["LongitudRepartidor"];

            MapboxNavigation navigation = new MapboxNavigation(this, MAPBOX_KEY);

            Point origin      = Point.FromLngLat(lngusr, latusr);
            Point destination = Point.FromLngLat(lngrep, latrep);

            var response = await NavigationRoute
                           .GetBuilder()
                           .AccessToken(Mapbox.AccessToken)
                           .Origin(origin)
                           .Destination(destination)
                           .Build()
                           .GetRouteAsync();

            System.Diagnostics.Debug.WriteLine(response);
        }
コード例 #3
0
        async void BuildRoute()
        {
            MapboxNavigation navigation = new MapboxNavigation(this, MAPBOX_KEY);

            Point origin      = Point.FromLngLat(-77.03613, 38.90992);
            Point destination = Point.FromLngLat(-77.0365, 38.8977);

            var response = await NavigationRoute
                           .GetBuilder()
                           .AccessToken(Mapbox.AccessToken)
                           .Origin(origin)
                           .Destination(destination)
                           .Build()
                           .GetRouteAsync();

            System.Diagnostics.Debug.WriteLine(response);
        }
コード例 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_reroute);

            mapView       = FindViewById <MapView>(Resource.Id.mapView);
            contentLayout = FindViewById(Android.Resource.Id.Content);

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

            // Initialize MapboxNavigation and add listeners
            MapboxNavigationOptions options = MapboxNavigationOptions
                                              .InvokeBuilder()
                                              .IsDebugLoggingEnabled(true)
                                              .Build();

            navigation = new MapboxNavigation(ApplicationContext, Mapbox.AccessToken, options);
            navigation.AddNavigationEventListener(this);
            navigation.AddMilestoneEventListener(this);
        }