Skip to main content
Version: 4.0

Wayfinding

Wayfinding is one of the most often used features of digital maps. This guide shows how to display a route from A to B using Mappedin Android SDK. It continues from a basic map display example.

Draw a route

Once the map is loaded, onFirstMapLoaded -callback is fired. If we set the following code in the callback, directions are rendered on the map as soon as the map is displayed.

First, we select two locations and then use mapView.getDirections to calculate the optimal path between the two. Then if there is a valid path between the departure and destination location, those are drawn using mapView.journeyManager.

The optional parameter pathOptions customizes the visual style of the path

override fun onFirstMapLoaded() {
val departure = mapView.venueData!!.locations.get(2);
val destination = mapView.venueData!!.locations.get(38);

mapView.getDirections(departure, destination) {
if (it != null) {
mapView.journeyManager.draw(it, MPIOptions.Journey(
pathOptions = MPIOptions.Path(
color = "green",
nearRadius = 2.5,
farRadius = 2.5
)
))
};
}
}