Loading...
Searching...
No Matches
RouteLayer Class Referenceabstract

Layer that renders a route on the map as traveled and remaining polylines. More...

Inherits Finalizable.

Public Member Functions

void setVisible (bool visible)
 Shows or hides the route layer.
 
bool isVisible ()
 Returns true if the route layer is visible.
 
void setTarget (RouteEndpoint target)
 Starts turn-by-turn guidance to the target from the current position.
 
void setRoute (RouteEndpoint from, RouteEndpoint to)
 Builds and shows a static route between two points (no live guidance).
 
void clear ()
 Cancels guidance / static route and removes polylines from the map.
 
List< RouteView > routes ()
 Returns currently rendered routes. V1 exposes a single active route.
 
RouteView selectedRoute ()
 Returns selected route view, or null when no route is selected.
 
void selectRoute (RouteView? route)
 Selects the provided route view. Pass null to clear selection.
 
void addRouteLayerListener (RouteLayerListener listener)
 Adds listener for route lifecycle, progress and target reach events.
 
void removeRouteLayerListener (RouteLayerListener listener)
 Removes previously added route layer listener.
 
void addRouteViewListener (RouteViewListener listener)
 Adds listener for route view list, selection and tap events.
 
void removeRouteViewListener (RouteViewListener listener)
 Removes previously added route view listener.
 
void setTraveledColor (Color color)
 Sets traveled (passed) route polyline color.
 
void setRemainingColor (Color color)
 Sets remaining route polyline color.
 
void setWidth (double width)
 Sets route polyline width in pixels (also used as default dotted point size).
 
void setRemainingStyle (RouteRemainingStyle style)
 Sets rendering style for the remaining route.
 
RouteRemainingStyle remainingStyle ()
 Returns the remaining route rendering style.
 
void setRemainingDashLength (double dashLength)
 Sets dash length for DASHED remaining style. Use 0 to disable dashing.
 
void setRemainingGapLength (double gapLength)
 Sets gap length for DASHED remaining style. Use 0 to disable dashing.
 
void setRemainingPointSize (double width, double height)
 Sets point size for DOTTED remaining style.
 
void setRemainingPlacement (Placement placement)
 Sets point placement mode for DOTTED remaining style.
 
void setRemainingPlacementSpacing (double spacing)
 Sets spacing between points for DOTTED + SPACED placement (pixels).
 
void setRemainingPlacementMinRatio (double ratio)
 Sets minimum polyline length ratio for DOTTED placement.
 
void setRemainingCollisionEnabled (bool enabled)
 Enables or disables collision for DOTTED remaining points.
 
bool isValid ()
 

Detailed Description

Layer that renders a route on the map as traveled and remaining polylines.

Independent from UserLocationLayer: a route can be shown without a user marker, and a user marker can be shown without a route.

Location and position are taken from the SDK automatically (same pattern as UserLocationLayer).

Referenced from NavigineSdk.

Definition at line 37 of file route_layer.dart.

Member Function Documentation

◆ addRouteLayerListener()

void RouteLayer.addRouteLayerListener ( RouteLayerListener listener)

Adds listener for route lifecycle, progress and target reach events.

Dart code snippet:

_routeLayerListener = DemoRouteLayerListener();
_routeLayer!.addRouteLayerListener(_routeLayerListener!);

◆ addRouteViewListener()

void RouteLayer.addRouteViewListener ( RouteViewListener listener)

Adds listener for route view list, selection and tap events.

Dart code snippet:

_routeViewListener = DemoRouteViewListener(_routeLayer!);
_routeLayer!.addRouteViewListener(_routeViewListener!);

◆ clear()

void RouteLayer.clear ( )

Cancels guidance / static route and removes polylines from the map.

Dart code snippet:

_routeLayer!.clear();
print("Route layer cleared");

◆ isValid()

bool RouteLayer.isValid ( )

◆ isVisible()

bool RouteLayer.isVisible ( )

Returns true if the route layer is visible.

Dart code snippet:

bool visible = _routeLayer!.isVisible();
print("Route layer is visible: $visible");

◆ remainingStyle()

RouteRemainingStyle RouteLayer.remainingStyle ( )

Returns the remaining route rendering style.

Dart code snippet:

RouteRemainingStyle remainingStyle = _routeLayer!.remainingStyle();
print("Remaining style: $remainingStyle");

◆ removeRouteLayerListener()

void RouteLayer.removeRouteLayerListener ( RouteLayerListener listener)

Removes previously added route layer listener.

◆ removeRouteViewListener()

void RouteLayer.removeRouteViewListener ( RouteViewListener listener)

Removes previously added route view listener.

◆ routes()

List< RouteView > RouteLayer.routes ( )

Returns currently rendered routes. V1 exposes a single active route.

Dart code snippet:

final routes = _routeLayer!.routes();
print("Visible routes: ${routes.length}");

◆ selectedRoute()

RouteView RouteLayer.selectedRoute ( )

Returns selected route view, or null when no route is selected.

Dart code snippet:

final selectedRoute = _routeLayer!.selectedRoute();
if (selectedRoute != null) {
print("Selected route length: ${selectedRoute.length()}");
}

◆ selectRoute()

void RouteLayer.selectRoute ( RouteView? route)

Selects the provided route view. Pass null to clear selection.

Parameters
routeRoute view from routes, or null.

Dart code snippet:

if (routes.isNotEmpty) {
_routeLayer!.selectRoute(routes.first);
}

◆ setRemainingCollisionEnabled()

void RouteLayer.setRemainingCollisionEnabled ( bool enabled)

Enables or disables collision for DOTTED remaining points.

Dart code snippet:

_routeLayer!.setRemainingCollisionEnabled(false);
print("Remaining collision disabled");

◆ setRemainingColor()

void RouteLayer.setRemainingColor ( Color color)

Sets remaining route polyline color.

Dart code snippet:

_routeLayer!.setRemainingColor(const Color(0xFF30AAD9));
print("Remaining color updated");

◆ setRemainingDashLength()

void RouteLayer.setRemainingDashLength ( double dashLength)

Sets dash length for DASHED remaining style. Use 0 to disable dashing.

Dart code snippet:

_routeLayer!.setRemainingDashLength(0.5);
print("Remaining dash length updated");

◆ setRemainingGapLength()

void RouteLayer.setRemainingGapLength ( double gapLength)

Sets gap length for DASHED remaining style. Use 0 to disable dashing.

Dart code snippet:

_routeLayer!.setRemainingGapLength(0.4);
print("Remaining gap length updated");

◆ setRemainingPlacement()

void RouteLayer.setRemainingPlacement ( Placement placement)

Sets point placement mode for DOTTED remaining style.

Dart code snippet:

_routeLayer!.setRemainingPlacement(Placement.SPACED);
print("Remaining placement updated");

◆ setRemainingPlacementMinRatio()

void RouteLayer.setRemainingPlacementMinRatio ( double ratio)

Sets minimum polyline length ratio for DOTTED placement.

Dart code snippet:

_routeLayer!.setRemainingPlacementMinRatio(0.0);
print("Remaining placement min ratio updated");

◆ setRemainingPlacementSpacing()

void RouteLayer.setRemainingPlacementSpacing ( double spacing)

Sets spacing between points for DOTTED + SPACED placement (pixels).

Dart code snippet:

_routeLayer!.setRemainingPlacementSpacing(8.0);
print("Remaining placement spacing updated");

◆ setRemainingPointSize()

void RouteLayer.setRemainingPointSize ( double width,
double height )

Sets point size for DOTTED remaining style.

Dart code snippet:

_routeLayer!.setRemainingPointSize(8.0, 8.0);
print("Remaining point size updated");

◆ setRemainingStyle()

void RouteLayer.setRemainingStyle ( RouteRemainingStyle style)

Sets rendering style for the remaining route.

Dart code snippet:

_routeLayer!.setRemainingStyle(RouteRemainingStyle.DOTTED);
print("Remaining style set to DOTTED");

◆ setRoute()

void RouteLayer.setRoute ( RouteEndpoint from,
RouteEndpoint to )

Builds and shows a static route between two points (no live guidance).

Parameters
fromRoute start endpoint.
toRoute finish endpoint.

Dart code snippet:

_routeLayer!.setRoute(from, to);
print("Static route applied");

◆ setTarget()

void RouteLayer.setTarget ( RouteEndpoint target)

Starts turn-by-turn guidance to the target from the current position.

Parameters
targetDestination endpoint. Route and progress are updated automatically.

Dart code snippet:

_routeLayer!.setTarget(to);
print("Guidance target applied");

◆ setTraveledColor()

void RouteLayer.setTraveledColor ( Color color)

Sets traveled (passed) route polyline color.

Dart code snippet:

_routeLayer!.setTraveledColor(const Color(0xB4787878));
print("Traveled color updated");

◆ setVisible()

void RouteLayer.setVisible ( bool visible)

Shows or hides the route layer.

Dart code snippet:

_routeLayer!.setVisible(true);
print("Route layer set visible");

◆ setWidth()

void RouteLayer.setWidth ( double width)

Sets route polyline width in pixels (also used as default dotted point size).

Dart code snippet:

_routeLayer!.setWidth(8.0);
print("Route width updated");

The documentation for this class was generated from the following file: