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
To query a multistop route a new overload MPDirectionsService.query
has been introduced MPDirectionsService.query(from: MPPoint, to: MPPoint, stops: List<MPPoint>?, optimize: Boolean)
.
Showing and configuring a multi-stop route on the map
With the introduction of the multi-stop routes. There has also been added new functionality to the MPDirectionsRenderer
to facilitate the new multi-stop routes.
You can still render the route as a Route with stops, using setRoute(route: MPRoute)
on the DirectionsRenderer. But the interface of the MPDirectionsRenderer
has been expanded with a defaultStopIcon
as well as an overload of: setRoute(route: MPRoute, icons: HashMap<Integer, MPRouteStopIconProvider>?)
The defaultStopIcon
can be configured to show any image. It can also be set to null, to not show any icon for the stops on the Route. We supply the MPRouteStopIconConfig
that allows you to customize the default pin to fit your application.
To use your own images, you can extend the MPRouteStopIconProvider with your own class. Here is an example using a bitmap for the image
Adding a custom image to a specific waypoint
It is also possible to render an image specific to a single stop. By using setRoute(route: MPRoute, icons: HashMap<Integer, MPRouteStopIconProvider>?)
Here we will show a blue icon for the third stop. Leaving the first two indexes as null, means that the renderer will use the defaultStopIcon
. If you want to render a specific known stop on an optimized route. You can find the ordering of the stops on an optimized route through MPRoute.orderedStopIndexes
.
Last updated