Text-based turn-by-turn directions can be a helpful aid to the map view and Blue Dot. Mappedin SDK for Android offers text directions whenever a route is requested.
var instructions = listOf<MPIDirections.MPIInstruction>()
mapView.getDirections(to = destination, from = departure) { directions -> directions?.instructions?.let { instructions = it }}
A complete class that uses the code snippets in this guide can be found in the Mappedin Android Github repo: TurnByTurnDirections.kt
Directions and Instructions
To request directions, call MPIMapView.getDirections() , which returns an MPIDirections object. MPIDirections provides the path as a list of MPINodes, the total walking distance in meters and a list of text-based instructions for navigation.
MPIInstruction list is used for turn-by-turn directions. The key components are:
instruction
text used to guide the userdistance
in meters for this instruction segment
The instruction
may include a store or a location name. That happens when the SDK is able to determine a relevant location nearby the instruction that could be helpful in navigating the venue.
The MPIAction includes an MPIActionType and MPIBearingType. These types represent what the user should do and the direction to do it.
The action
object can be used to localize instructions. The Mappedin SDK provides the following action and bearing text in English only. The text could be substituted for another language before being displayed to a user.
- MPIActionType.ARRIVAL = Arrival
- MPIActionType.DEPARTURE = Departure
- MPIActionType.EXITVORTEX = ExitVortex
- MPIActionType.TAKEVORTEX = TakeVortex
- MPIActionType.TURN = Turn
- MPIBearingType.LEFT = Left
- MPIBearingType.RIGHT = Right
- MPIBearingType.SLIGHTLEFT = SlightLeft
- MPIBearingType.SLIGHTRIGHT = SlightRight
- MPIBearingType.STRAIGHT = Straight
A complete class that uses the code snippets in this guide can be found in the Mappedin Android Github repo: TurnByTurnDirections.kt