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.xml file, 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.

    • Constructor Detail

    • 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
      • 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
      • 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
      • 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.