Route Visualization (v2.1.x - Android)

The core component of Navmii SDK responsible for visualization of route-related data is RouteVisualizer. This class provides the API to render routes, alternative routes and waypoint markers on map.

CREATING ROUTE VISUALIZER

Sdk class contains the getRouteVisualizer method providing access to the instance of route visualizer. The route visualizer instance can be accessed only after the SDK was started.

VISUALIZING THE DATA

RouteVisualizer class has the performRequest method which allows to execute a route-related data visualization request. The specified request parameter contains data to visualize.

Note that visualization request, once performed, affects global SDK state, therefore it's user's responsibility to handle the state correctly.

Route visualization request is the instance of RouteVisualizerRequest class.

RouteVisualizerRequest can be configured to perform the following actions:

  • set or remove an active route (active route polyline is rendered with route color and traffic is displayed on it);

  • set or remove any number of alternative routes (alternative routes are rendered with grey color and traffic is displayed on it);

  • set or remove route waypoint markers, including special markers for start and finish points.

CREATING ROUTE VISUALIZATION REQUEST

Navmii SDK contains the RouteVisualizerRequest class which should be used to create requests configured to render the required data on map.

As you can see from the interface of RouteVisualizerRequest class, it allows to construct a request which performs multiple operations (i.e. to set an active route, to set one or multiple alternative routes and to set way-point markers) within the single request. This is the preferred way to handle the visualizer state in terms of performance as each route visualizer request, once executed, requires map tiles to be re-created.

If possible, try to create a single request configured to perform all the required actions rather than creating a new request for each action. The less often the performRequest method of RouteVisualizer is called, the better.

VISUALIZING ROUTES

The RouteVisualizerRequest class contains the requestDisplayingPolylineOfRoute method which allows to create an RouteVisualizerRequest instance configured so that the new request, in addition to the previously configured actions, will display the active route polyline on map. The route parameter is an instance of Route class which is used to get a polyline to render. The parameters parameter allows configuring the appearance of the route (see this page for details).

When waypoints are enabled, the special start point marker (the blue flag) is used for route origin, special finish point marker (black-and-white flag) is used for route destination, intermediate waypoints are rendered with yellow flag.

The requestDisplayingPolylinesOfAlternativeRoutes method allows to create a RouteVisualizerRequest instance configured so that the new request, in addition to the previously configured actions, will display alternative route polylines on map. The routes parameter is an array of alternative routes. Each route is an instance of Route class which is used to get a polyline to render. The parameters parameter allows configuring the appearance of the polylines.

The requestRemovingRoutePolyline and requestRemovingAlternativeRoutePolylines methods allow to create an RouteVisualizerRequest instance configured so that the new request, in addition to the previously configured actions, will remove the active and the alternative route polylines respectively.

VISUALIZING WAYPOINT MARKERS

The RouteVisualizerRequest contains the requestDisplayingWaypointMarkersAtCoordinates method which allows to render waypoint markers on map. The coordinates parameter specifies an array of waypoint marker coordinates. Each coordinate is an instance of MapCoordinates class. The special finish marker (black-and-white flag) is used for the last waypoint. The special start marker (blue flag) is used for the first waypoint if true is specified for the considerFirstOneAsStart parameter, otherwise the regular waypoint marker (yellow flag) is used. The regular marker is also used for all other waypoints.

The requestRemovingWaypointMarkers method allows to create an RouteVisualizerRequest instance configured so that the new request, in addition to the previously configured actions, will remove all the waypoint markers from map.

Route markers can be customized using RouteDisplayParameters. See this page for details.

ROUTE VISUALIZER BINDING

RouteVisualizer class has a performRequest method that allows to bind route visualizer to a source of route visualizer requests. The only source of route visualizer requests in Navmii SDK is RouteNavigator class, which is able to render the route being navigated. To achieve such a behaviour you need to connect the route visualizer (getRouteVisualizer method of Sdk) to the route navigator (getRouteNavigator method of Sdk) using addRouteVisualizerRequestListener method of RouteNavigatorYou are able to implement your own route visualizer request source if you need to.