Example #1
0
        // Demonstrates how to make an asynchronous directions request.
        void AsyncMapboxDirectionsRequest()
        {
            // 1. Pass in all the required information to get a route.
            var request = MapboxDirections.InvokeBuilder()
                          .AccessToken(GetString(Resource.String.access_token))
                          .Origin(Point.FromLngLat(-95.6332, 29.7890))
                          .Destination(Point.FromLngLat(-95.3591, 29.7576))
                          .Profile(DirectionsCriteria.ProfileCycling)
                          .Steps((Java.Lang.Boolean)true)
                          .Build();

            // 2. Now request the route using a async call
            request.EnqueueCall(new AsyncMapboxDirectionsCallback());
        }
        public void RequestDirectionsRoute(Point origin, Point destination)
        {
            MapboxDirections directions = MapboxDirections
                                          .InvokeBuilder()
                                          .Origin(origin)
                                          .Destination(destination)
                                          .AccessToken(Mapbox.AccessToken)
                                          .Profile(DirectionsCriteria.ProfileDrivingTraffic)
                                          .Overview(DirectionsCriteria.OverviewFull)
                                          .Annotations(DirectionsCriteria.AnnotationCongestion)
                                          .Alternatives(new Java.Lang.Boolean(true))
                                          .Steps(new Java.Lang.Boolean(true))
                                          .Build();

            directions.EnqueueCall(this);
        }
Example #3
0
        // Demonstrates how to make the most basic directions request.
        void SimpleMapboxDirectionsRequest()
        {
            var builder = MapboxDirections.InvokeBuilder();

            // 1. Pass in all the required information to get a simple directions route.
            builder.AccessToken(GetString(Resource.String.access_token));
            builder.Origin(Point.FromLngLat(-95.6332, 29.7890));
            builder.Destination(Point.FromLngLat(-95.3591, 29.7576));

            // 2. That's it! Now execute the command and get the response.
            var response = builder.Build().ExecuteCall();

            // 3. Log information from the response
            System.Diagnostics.Debug.WriteLine("From SimpleMapboxDirectionsRequest");
            System.Diagnostics.Debug.WriteLine(
                $"Check that the response is successful {response.IsSuccessful}");

            var body = response.Body() as DirectionsResponse;

            System.Diagnostics.Debug.WriteLine(
                $"Get the first routes distance from origin to destination: {body.Routes()[0].Distance()}");
        }