Mapbox Vision AR for Android is a high-level framework that sits on top of the Mapbox Vision SDK for Android. Vision AR manages the navigation route, translates it to the core library, and renders an AR navigation route on top of the live video stream from the device’s built-in camera.
To project a route line on the road, start by generating the route. You can use the Mapbox Navigation SDK to create a new request to the Mapbox Directions API or use a custom navigation engine. If you want to use the Mapbox Navigation SDK for Android, you will need to add it as a dependency following the instructions in the Navigation SDK documentation.
The example below uses the Mapbox Navigation SDK for Android's
NavigationRoute.Builder class to create a new request to the Mapbox Directions API. The response will be a
NavigationRoute object, which you can use to display a route on a map or start a navigation sequence. Read more about generating routes with the Navigation SDK in the Route generation guide.
setRoute method to use the generated route in a Vision AR view.
VisionArManager.setRoute(new Route(getRoutePoints(route),(float) routeProgress.durationRemaining(),"Source street name","Target street name"));
By default green AR navigation lane is used to display the route. Some customization is possible. Use
VisionArView.setLaneVisualParams to change color, width, and arrow length.
To display maneuvers, enable AR fences using the
VisionArView.setFenceVisible method. Use
VisionArView.setFenceVisualParams to change color, horizontal and vertical offsets, and section number.