Loading...
Searching...
No Matches

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

#include <com/navigine/idl/objc/NCRouteLayer.h>

Inherits NSObject.

Instance Methods

(void) - setVisible:
 Shows or hides the route layer.
 
(BOOL) - isVisible
 Returns true if the route layer is visible.
 
(void) - setTarget:
 Starts turn-by-turn guidance to the target from the current position.
 
(void) - setRoute: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.
 
(nonnull NSArray< NCRouteView * > *) - routes
 Returns currently rendered routes. V1 exposes a single active route.
 
(nullable NCRouteView *) - selectedRoute
 Returns selected route view, or null when no route is selected.
 
(void) - selectRoute:
 Selects the provided route view. Pass null to clear selection.
 
(void) - addRouteLayerListener:
 Adds listener for route lifecycle, progress and target reach events.
 
(void) - removeRouteLayerListener:
 Removes previously added route layer listener.
 
(void) - addRouteViewListener:
 Adds listener for route view list, selection and tap events.
 
(void) - removeRouteViewListener:
 Removes previously added route view listener.
 
(void) - setTraveledColor:
 Sets traveled (passed) route polyline color.
 
(void) - setRemainingColor:
 Sets remaining route polyline color.
 
(void) - setWidth:
 Sets route polyline width in pixels (also used as default dotted point size).
 
(void) - setRemainingStyle:
 Sets rendering style for the remaining route.
 
(NCRouteRemainingStyle) - remainingStyle
 Returns the remaining route rendering style.
 
(void) - setRemainingDashLength:
 Sets dash length for DASHED remaining style. Use 0 to disable dashing.
 
(void) - setRemainingGapLength:
 Sets gap length for DASHED remaining style. Use 0 to disable dashing.
 
(void) - setRemainingPointSize:height:
 Sets point size for DOTTED remaining style.
 
(void) - setRemainingPlacement:
 Sets point placement mode for DOTTED remaining style.
 
(void) - setRemainingPlacementSpacing:
 Sets spacing between points for DOTTED + SPACED placement (pixels).
 
(void) - setRemainingPlacementMinRatio:
 Sets minimum polyline length ratio for DOTTED placement.
 
(void) - setRemainingCollisionEnabled:
 Enables or disables collision for DOTTED remaining points.
 

Properties

BOOL valid
 

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 32 of file NCRouteLayer.h.

Method Documentation

◆ addRouteLayerListener:

- (void) addRouteLayerListener: (nullable id< NCRouteLayerListener >) listener

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

Swift code snippet:

routeLayerListener = DemoRouteLayerListener()
routeLayer.addRouteLayerListener(routeLayerListener)

Objective C code snippet:

◆ addRouteViewListener:

- (void) addRouteViewListener: (nullable id< NCRouteViewListener >) listener

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

Swift code snippet:

routeViewListener = DemoRouteViewListener(routeLayer: routeLayer)
routeLayer.addRouteViewListener(routeViewListener)

Objective C code snippet:

◆ clear

- (void) clear

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

Swift code snippet:

routeLayer.clear()
print("Route layer cleared")

Objective C code snippet:

NSLog(@"Route layer cleared");

◆ isVisible

- (BOOL) isVisible

Returns true if the route layer is visible.

Swift code snippet:

let visible = routeLayer.isVisible()
print("Route layer is visible: \‍(visible)")

Objective C code snippet:

BOOL visible = [_routeLayer isVisible];
NSLog(@"Route layer is visible: %d", visible);

◆ remainingStyle

- (NCRouteRemainingStyle) remainingStyle

Returns the remaining route rendering style.

Swift code snippet:

let remainingStyle = routeLayer.remainingStyle()
print("Remaining style: \‍(remainingStyle)")

Objective C code snippet:

NSLog(@"Remaining style: %ld", (long)remainingStyle);

◆ removeRouteLayerListener:

- (void) removeRouteLayerListener: (nullable id< NCRouteLayerListener >) listener

Removes previously added route layer listener.

◆ removeRouteViewListener:

- (void) removeRouteViewListener: (nullable id< NCRouteViewListener >) listener

Removes previously added route view listener.

◆ routes

- (nonnull NSArray< NCRouteView * > *) routes

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

Swift code snippet:

let routes = routeLayer.routes()
print("Visible routes: \‍(routes.count)")

Objective C code snippet:

NSArray<id<NCRouteView>> *routes = [_routeLayer routes];
NSLog(@"Visible routes: %lu", (unsigned long)routes.count);

◆ selectedRoute

- (nullable NCRouteView *) selectedRoute

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

Swift code snippet:

if let selectedRoute = routeLayer.selectedRoute() {
print("Selected route length: \‍(selectedRoute.length())")
}

Objective C code snippet:

id<NCRouteView> selectedRoute = [_routeLayer selectedRoute];
if (selectedRoute != nil) {
NSLog(@"Selected route length: %f", [selectedRoute length]);
}

◆ selectRoute:

- (void) selectRoute: (nullable NCRouteView *) route

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

Parameters
routeRoute view from routes, or null.

Swift code snippet:

if let firstRoute = routes.first {
routeLayer.selectRoute(firstRoute)
}

Objective C code snippet:

if (routes.count > 0) {
[_routeLayer selectRoute:routes.firstObject];
}

◆ setRemainingCollisionEnabled:

- (void) setRemainingCollisionEnabled: (BOOL) enabled

Enables or disables collision for DOTTED remaining points.

Swift code snippet:

routeLayer.setRemainingCollisionEnabled(false)
print("Remaining collision disabled")

Objective C code snippet:

NSLog(@"Remaining collision disabled");

◆ setRemainingColor:

- (void) setRemainingColor: (nonnull UIColor *) color

Sets remaining route polyline color.

Swift code snippet:

routeLayer.setRemainingColor(UIColor(red: 0.19, green: 0.67, blue: 0.85, alpha: 1.0))
print("Remaining color updated")

Objective C code snippet:

[_routeLayer setRemainingColor:[UIColor colorWithRed:0.19 green:0.67 blue:0.85 alpha:1.0]];
NSLog(@"Remaining color updated");

◆ setRemainingDashLength:

- (void) setRemainingDashLength: (float) dashLength

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

Swift code snippet:

routeLayer.setRemainingDashLength(0.5)
print("Remaining dash length updated")

Objective C code snippet:

NSLog(@"Remaining dash length updated");

◆ setRemainingGapLength:

- (void) setRemainingGapLength: (float) gapLength

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

Swift code snippet:

routeLayer.setRemainingGapLength(0.4)
print("Remaining gap length updated")

Objective C code snippet:

NSLog(@"Remaining gap length updated");

◆ setRemainingPlacement:

- (void) setRemainingPlacement: (NCPlacement) placement

Sets point placement mode for DOTTED remaining style.

Swift code snippet:

routeLayer.setRemainingPlacement(.SPACED)
print("Remaining placement updated")

Objective C code snippet:

[_routeLayer setRemainingPlacement:NCPlacementSpaced];
NSLog(@"Remaining placement updated");

◆ setRemainingPlacementMinRatio:

- (void) setRemainingPlacementMinRatio: (float) ratio

Sets minimum polyline length ratio for DOTTED placement.

Swift code snippet:

routeLayer.setRemainingPlacementMinRatio(0.0)
print("Remaining placement min ratio updated")

Objective C code snippet:

NSLog(@"Remaining placement min ratio updated");

◆ setRemainingPlacementSpacing:

- (void) setRemainingPlacementSpacing: (float) spacing

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

Swift code snippet:

routeLayer.setRemainingPlacementSpacing(8.0)
print("Remaining placement spacing updated")

Objective C code snippet:

NSLog(@"Remaining placement spacing updated");

◆ setRemainingPointSize:height:

- (void) setRemainingPointSize: (float) width
height: (float) height 

Sets point size for DOTTED remaining style.

Swift code snippet:

routeLayer.setRemainingPointSize(8.0, height: 8.0)
print("Remaining point size updated")

Objective C code snippet:

NSLog(@"Remaining point size updated");

◆ setRemainingStyle:

- (void) setRemainingStyle: (NCRouteRemainingStyle) style

Sets rendering style for the remaining route.

Swift code snippet:

routeLayer.setRemainingStyle(.DOTTED)
print("Remaining style set to DOTTED")

Objective C code snippet:

[_routeLayer setRemainingStyle:NCRouteRemainingStyleDotted];
NSLog(@"Remaining style set to DOTTED");

◆ setRoute:to:

- (void) setRoute: (nonnull NCRouteEndpoint *) from
to: (nonnull NCRouteEndpoint *) to 

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

Parameters
fromRoute start endpoint.
toRoute finish endpoint.

Swift code snippet:

routeLayer.setRoute(from, to: to)
print("Static route applied")

Objective C code snippet:

[_routeLayer setRouteFrom:from to:to];
NSLog(@"Static route applied");

◆ setTarget:

- (void) setTarget: (nonnull NCRouteEndpoint *) target

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

Parameters
targetDestination endpoint. Route and progress are updated automatically.

Swift code snippet:

routeLayer.setTarget(to)
print("Guidance target applied")

Objective C code snippet:

NSLog(@"Guidance target applied");

◆ setTraveledColor:

- (void) setTraveledColor: (nonnull UIColor *) color

Sets traveled (passed) route polyline color.

Swift code snippet:

routeLayer.setTraveledColor(UIColor(red: 0.47, green: 0.47, blue: 0.47, alpha: 0.7))
print("Traveled color updated")

Objective C code snippet:

[_routeLayer setTraveledColor:[UIColor colorWithRed:0.47 green:0.47 blue:0.47 alpha:0.7]];
NSLog(@"Traveled color updated");

◆ setVisible:

- (void) setVisible: (BOOL) visible

Shows or hides the route layer.

Swift code snippet:

routeLayer.setVisible(true)
print("Route layer set visible")

Objective C code snippet:

NSLog(@"Route layer set visible");

◆ setWidth:

- (void) setWidth: (float) width

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

Swift code snippet:

routeLayer.setWidth(8.0)
print("Route width updated")

Objective C code snippet:

NSLog(@"Route width updated");

Property Documentation

◆ valid

- (BOOL) valid
readnonatomicassign

Tells if this object is valid or not. Any method called on an invalid object will throw an exception. The object becomes invalid only on UI thread, and only when its implementation depends on objects already destroyed by now.

Definition at line 388 of file NCRouteLayer.h.


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