Using multi-stop navigation
Multi-stop navigation has been introduced with the release of 4.8.0. This allows users to be navigated to multiple stops within a single route.
Querying a multi-stop route
private var directionsService: MPDirectionsService = MPDirectionsService()
//Example of querying an optimized route with multiple stops
fun getRoute() {
if (directionsService != null) {
directionsService = MPDirectionsService()
}
//Setting listener to receive the queried route
directionsService.setRouteResultListener { route, error ->
if (error == null && route != null) {
//Route is received
} else {
Log.i("Directions", "Error: $error")
}
}
//Creating variables to use for the query
val origin = MPPoint(57.05800975, 9.949916517)
val destination = MPPoint(57.058278, 9.9512196, 10.0)
val stops = listOf(MPPoint(57.0582701, 9.9508396, 0.0), MPPoint(57.0580431, 9.9505475, 0.0), MPPoint(57.0580843, 9.9506085, 10.0))
directionsService.query(origin, destination, stops, true)
}Showing and configuring a multi-stop route on the map


Adding a custom image to a specific waypoint
Last updated
Was this helpful?