Esempio n. 1
0
        private void FetchRoute()
        {
            NavigationRoute.Builder builder = NavigationRoute.InvokeBuilder(this)
                                              .AccessToken(Mapbox.Mapboxsdk.Mapbox.AccessToken)
                                              .Origin(currentLocation)
                                              .Profile(GetRouteProfileFromSharedPreferences())
                                              .Alternatives((Java.Lang.Boolean)true);

            foreach (Point wayPoint in wayPoints)
            {
                builder.AddWaypoint(wayPoint);
            }

            SetFieldsFromSharedPreferences(builder);
            builder.Build().GetRoute(new MyGetRouteCallback((routes) =>
            {
                HideLoading();
                route = routes[0];
                if (Convert.ToInt32(route.Distance()) > 25)
                {
                    launchRouteBtn.Enabled = true;
                    map.DrawRoutes(routes);
                    BoundCameraToRoute();
                }
                else
                {
                    Snackbar.Make(mapView, Resource.String.error_select_longer_route, Snackbar.LengthShort).Show();
                }
            }));
            loading.Visibility = ViewStates.Visible;
        }
Esempio n. 2
0
 private void GetRoute(Point origin, Point destination)
 {
     NavigationRoute.InvokeBuilder(this)
     .Origin(origin)
     .Destination(destination)
     .AccessToken(Mapbox.Mapboxsdk.Mapbox.AccessToken)
     .Build().GetRoute(this);
 }
Esempio n. 3
0
 public void FindRoute(Point origin, Point destination)
 {
     NavigationRoute.InvokeBuilder(this)
     .AccessToken(Mapbox.Mapboxsdk.Mapbox.AccessToken)
     .Origin(origin)
     .Destination(destination)
     .Alternatives((Java.Lang.Boolean)true)
     .Build()
     .GetRoute(this);
 }
        private void FetchRoute()
        {
            NavigationRoute builder = NavigationRoute.InvokeBuilder(this)
                                      .AccessToken(GetString(Resource.String.mapbox_access_token))
                                      .Origin(origin)
                                      .Destination(destination)
                                      .Alternatives((Java.Lang.Boolean)true)
                                      .Build();

            builder.GetRoute(this);
        }
Esempio n. 5
0
        private void CalculateRouteWith(Point destination, bool isOffRoute)
        {
            Point  origin  = Point.FromLngLat(lastLocation.Longitude, lastLocation.Latitude);
            double bearing = (double)lastLocation.Bearing;

            NavigationRoute.InvokeBuilder(this)
            .AccessToken(Mapbox.Mapboxsdk.Mapbox.AccessToken)
            .Origin(origin, (Java.Lang.Double)bearing, (Java.Lang.Double)BEARING_TOLERANCE)
            .Destination(destination)
            .Build()
            .GetRoute(new SimplifiedCallback((response) =>
            {
                HandleRoute(response, isOffRoute);
            }));
        }
Esempio n. 6
0
        private void FetchRoute()
        {
            NavigationRoute builder = NavigationRoute.InvokeBuilder(this)
                                      .AccessToken(Mapbox.Mapboxsdk.Mapbox.AccessToken)
                                      .Origin(origin)
                                      .Profile(DirectionsCriteria.ProfileDriving)
                                      .AddWaypoint(pickup)
                                      .AddWaypoint(middlePickup)
                                      .Destination(destination)
                                      .AddWaypointIndices(new Integer(0), new Integer(2), new Integer(3))
                                      .Alternatives((Java.Lang.Boolean)true)
                                      .Build();

            builder.GetRoute(this);
            UpdateLoadingTo(true);
        }
 private void FetchRoute(Point origin, Point destination)
 {
     NavigationRoute.InvokeBuilder(Context)
     .AccessToken(Mapbox.Mapboxsdk.Mapbox.AccessToken)
     .Origin(origin)
     .Destination(destination)
     .Build()
     .GetRoute(new SimplifiedCallback((response) =>
     {
         var body = response.Body() as DirectionsResponse;
         if (body != null && body.Routes().Any())
         {
             directionsRoute = body.Routes()[0];
             StartNavigation();
         }
     }));
 }
Esempio n. 8
0
 private void FetchRoute(Point origin, Point destination)
 {
     NavigationRoute.InvokeBuilder(this)
     .AccessToken(Mapbox.Mapboxsdk.Mapbox.AccessToken)
     .Origin(origin)
     .Destination(destination)
     .Alternatives((Java.Lang.Boolean)true)
     .Build()
     .GetRoute(new SimplifiedCallback((res) =>
     {
         var body = res.Body() as DirectionsResponse;
         if (body != null && body.Routes().Any())
         {
             StartNavigation(body.Routes()[0]);
         }
     }));
 }
        private void FindRouteWith(LocationEngineResult result)
        {
            Location userLocation = result.LastLocation;

            if (userLocation == null)
            {
                Timber.D("calculateRoute: User location is null, therefore, origin can't be set.");
                return;
            }
            Point origin = Point.FromLngLat(userLocation.Longitude, userLocation.Latitude);

            if (TurfMeasurement.Distance(origin, destination, TurfConstants.UnitMeters) < 50)
            {
                startRouteButton.Visibility = ViewStates.Gone;
                return;
            }

            NavigationRoute.Builder navigationRouteBuilder = NavigationRoute.InvokeBuilder(this)
                                                             .AccessToken(Mapbox.Mapboxsdk.Mapbox.AccessToken);
            navigationRouteBuilder.Origin(origin);
            navigationRouteBuilder.Destination(destination);
            if (waypoint != null)
            {
                navigationRouteBuilder.AddWaypoint(waypoint);
            }
            navigationRouteBuilder.EnableRefresh(true);
            navigationRouteBuilder.Build().GetRoute(new GetRouteCallback((response) =>
            {
                if (response != null && response.Routes().Any())
                {
                    route = response.Routes()[0];
                    navigationMapRoute.AddRoutes(response.Routes());
                    startRouteButton.Visibility = ViewStates.Visible;
                }
            }));
        }