Loading...

Turn-by-Turn Directions

Text-based turn-by-turn directions can be a helpful aid to the map view and Blue Dot. Mappedin SDK for iOS offers text directions whenever a route is requested.

mapView?.getDirections(to: destination, from: departure) {
directions in
instructions = directions?.instructions ?? [MPIInstruction]()
}

A complete class that uses the code snippets in this guide can be found in the Mappedin iOS Github repo: TurnByTurnDirections.kt

Directions and Instructions

To request directions, call MPIMapView.getDirections(to: MPIDestinationSet...) or MPIMapView.getDirections(to: MPINavigatable...), which returns an MPIDirections object. MPIDirections provides the path as an array of MPINodes, the total walking distance in meters and a list of text-based instructions for navigation.

MPIInstruction array is used for turn-by-turn directions. The key components are:

  • instruction text used to guide the user
  • distance 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

  • MPIActionType.ARRIVAL = Arrival
  • MPIActionType.DEPARTURE = Departure
  • MPIActionType.EXITVORTEX = ExitVortex
  • MPIActionType.TAKEVORTEX = TakeVortex
  • MPIActionType.TURN = Turn

MPIBearingType

  • 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 iOS Github repo: TurnByTurnDirections.kt

Was this page helpful?

Next Topic

Camera Controls