private static void simpleMapboxDirectionsRequest ( ) throws IOException { MapboxDirections . Builder builder = MapboxDirections . builder ( ) ; // 1. Pass in all the required information to get a simple directions route. builder . accessToken ( BuildConfig . MAPBOX_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. Response < DirectionsResponse > response = builder . build ( ) . executeCall ( ) ; // 3. Log information from the response System . out . printf ( "Check that the GET response is successful %b" , response . isSuccessful ( ) ) ; System . out . printf ( "%nGet the first routes distance from origin to destination: %f" , response . body ( ) . routes ( ) . get ( 0 ) . distance ( ) ) ; }
Demonstrates how to make the most basic GET directions request .