The routing plugin allows you to generate safe and legal routes for commercial vehicles and display those routes on the map. To use the plugin:
In the dependencies of the project’s gradle file, add the code below to get access to the features in the plugin.
When initializing the
RoutePlugin, you can customize the stop icons and the text color used to draw routes. The code below depicts how you can do this:
|The MapView to apply the route plugin to.|
|The TrimbleMapsMap to apply route plugin with.|
|The layer id where you’d like the route to display below.|
|Custom Drawable to use for the first stop (origin).|
|Custom Drawable to use for the last stop (destination).|
|Custom Drawable to use for the intermediate stops.|
|Custom color to use for the stop numbers on the intermediate stop icons.|
Once we have a valid route, we can pass that route into the RoutePlugin and it will draw the route on the map.
If you want to clear the route via the RoutePlugin, you just use
You can also frame the route passed with the
frameRoutes() method. You have the option to set custom padding to the frame if you wish to zoom out or zoom in to the route drawn.
In order to use the route plugin, you must first create a route to pass in. To generate a route, you need to define and initiate the
RouteOptions. If there are only two stops in a trip, then the
coordinates origin and destination should be defined and the intermediate stops can be null. If a trip has more than one stop, then you need to define the origin and destination, and put all the other stops in
Now we can pass the
routeOptions to a
route can be added to the