private static void asyncMapboxDirectionsRequest ( ) { // 1. Pass in all the required information to get a route. MapboxDirections request = MapboxDirections . builder ( ) . accessToken ( BuildConfig . MAPBOX_ACCESS_TOKEN ) . origin ( Point . fromLngLat ( - 95.6332 , 29.7890 ) ) . destination ( Point . fromLngLat ( - 95.3591 , 29.7576 ) ) . profile ( DirectionsCriteria . PROFILE_CYCLING ) . steps ( true ) . build ( ) ; // 2. Now request the route using a async call request . enqueueCall ( new Callback < DirectionsResponse > ( ) { @ Override public void onResponse ( Call < DirectionsResponse > call , Response < DirectionsResponse > response ) { // 3. Log information from the response if ( response . isSuccessful ( ) ) { System . out . printf ( "%nGet the street name of the first step along the route: %s" , response . body ( ) . routes ( ) . get ( 0 ) . legs ( ) . get ( 0 ) . steps ( ) . get ( 0 ) . name ( ) ) ; } } @ Override public void onFailure ( Call < DirectionsResponse > call , Throwable throwable ) { System . err . println ( throwable ) ; } } ) ; }
Demonstrates how to make an asynchronous directions request .