Class NavigationMapRoute
-
- All Implemented Interfaces:
-
androidx.lifecycle.LifecycleObserver
@UiThread() public class NavigationMapRoute implements LifecycleObserver
Provide a route using addRoutes and a route will be drawn using runtime styling. The route will automatically be placed below all labels independent of specific style. If the map styles changed when a routes drawn on the map, the route will automatically be redrawn onto the new map style.
You are given the option when first constructing an instance of this class to pass in a style resource. This allows for custom colorizing and line scaling of the route. Inside your applications
style.xmlfile, you extend<style name="NavigationMapRoute">and change some or all the options currently offered. If no style files provided in the constructor, the default style will be used.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classNavigationMapRoute.BuilderThe Builder of NavigationMapRoute.
-
Method Summary
Modifier and Type Method Description voidaddRoute(DirectionsRoute directionsRoute)Allows adding a single primary route for the user to traverse along. voidaddRoutes(@NonNull() List<out DirectionsRoute> directionsRoutes, TrimbleMapsTrip trimbleMapsTrip, int stopNumberOffset)Provide a list of DirectionsRoutes, the primary route will default to the first route in the directions route list. voidaddIdentifiableRoute(IdentifiableRoute directionsRoute)voidaddIdentifiableRoutes(@NonNull() @Size(min = 1) List<IdentifiableRoute> directionsRoutes)voidupdateRouteVisibilityTo(boolean isVisible)Hides all routes on the map drawn by this class. voidupdateRouteArrowVisibilityTo(boolean isVisible)Hides the progress arrow on the map drawn by this class. voidshowAlternativeRoutes(boolean alternativesVisible)Toggle whether or not you'd like the map to display the alternative routes. voidaddProgressChangeListener(@NonNull() TrimbleMapsNavigation navigation)This method will allow this class to listen to route progress and adapt the route line whenever STARTED. voidremoveProgressChangeListener(@Nullable() TrimbleMapsNavigation navigation)Should be called if addProgressChangeListener was called to prevent leaking. voidonNewRouteProgress(@NonNull() RouteProgress routeProgress)Can be used to manually update the route progress. voidsetOnRouteSelectionChangeListener(@Nullable() OnRouteSelectionChangeListener onRouteSelectionChangeListener)Add a OnRouteSelectionChangeListener to know which route the user has currently selected as their primary route. voidsetVanishRouteLineEnabled(boolean enabled)Determines whether or not the vanishing route line feature is enabled.
-
-
-
Method Detail
-
addRoute
void addRoute(DirectionsRoute directionsRoute)
Allows adding a single primary route for the user to traverse along. No alternative routes will be drawn on top of the map. The route added will replace any previously added route(s).
- Parameters:
directionsRoute- the directions route which you'd like to display on the map
-
addRoutes
void addRoutes(@NonNull() List<out DirectionsRoute> directionsRoutes, TrimbleMapsTrip trimbleMapsTrip, int stopNumberOffset)
Provide a list of DirectionsRoutes, the primary route will default to the first route in the directions route list. All other routes in the list will be drawn on the map using the alternative route style. The routes passed to this method will replace any previously added routes. Passing an empty list will clear the routes.
- Parameters:
directionsRoutes- a list of direction routes, first one being the primary and the rest of the routes are considered alternatives.stopNumberOffset- offset to add to the waypoint index when drawing the stop number icons
-
addIdentifiableRoute
void addIdentifiableRoute(IdentifiableRoute directionsRoute)
-
addIdentifiableRoutes
void addIdentifiableRoutes(@NonNull() @Size(min = 1) List<IdentifiableRoute> directionsRoutes)
-
updateRouteVisibilityTo
void updateRouteVisibilityTo(boolean isVisible)
Hides all routes on the map drawn by this class.
- Parameters:
isVisible- true to show routes, false to hide
-
updateRouteArrowVisibilityTo
void updateRouteArrowVisibilityTo(boolean isVisible)
Hides the progress arrow on the map drawn by this class.
- Parameters:
isVisible- true to show routes, false to hide
-
showAlternativeRoutes
void showAlternativeRoutes(boolean alternativesVisible)
Toggle whether or not you'd like the map to display the alternative routes. This options great for when the user actually begins the navigation session and alternative routes aren't needed anymore.
- Parameters:
alternativesVisible- true if you'd like alternative routes to be displayed on the map, else false
-
addProgressChangeListener
void addProgressChangeListener(@NonNull() TrimbleMapsNavigation navigation)
This method will allow this class to listen to route progress and adapt the route line whenever STARTED. In order to use the vanishing route line feature be sure to enable the feature before calling this method.
- Parameters:
navigation- to add the progress change listener
-
removeProgressChangeListener
void removeProgressChangeListener(@Nullable() TrimbleMapsNavigation navigation)
Should be called if addProgressChangeListener was called to prevent leaking.
- Parameters:
navigation- to remove the progress change listener
-
onNewRouteProgress
void onNewRouteProgress(@NonNull() RouteProgress routeProgress)
Can be used to manually update the route progress.
NavigationMapRoute automatically listens to onRouteProgressChanged when a progress observer is subscribed with addProgressChangeListener and invoking this method in that scenario will lead to competing updates.
- Parameters:
routeProgress- current progress
-
setOnRouteSelectionChangeListener
void setOnRouteSelectionChangeListener(@Nullable() OnRouteSelectionChangeListener onRouteSelectionChangeListener)
Add a OnRouteSelectionChangeListener to know which route the user has currently selected as their primary route.
- Parameters:
onRouteSelectionChangeListener- a listener which lets you know when the user has changed the primary route and provides the current direction route which the user has selected
-
setVanishRouteLineEnabled
void setVanishRouteLineEnabled(boolean enabled)
Determines whether or not the vanishing route line feature is enabled. This should be called prior to adding a ProgressChangeListener if this feature wasn't enabled via the builder.
-
-