Skip to content

Commit

Permalink
Add support for carplay to hide waypoints from route line
Browse files Browse the repository at this point in the history
  • Loading branch information
chizhavko committed Mar 6, 2024
1 parent c09a4b8 commit cb93c46
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/MapboxNavigation/CarPlayManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,18 @@ extension CarPlayManager: CPMapTemplateDelegate {
// MARK: CarPlayNavigationViewControllerDelegate Methods

extension CarPlayManager: CarPlayNavigationViewControllerDelegate {
public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController,
waypointCircleLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> MapboxMaps.CircleLayer? {
delegate?.carPlayManager(self, waypointCircleLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
}

public func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController,
waypointSymbolLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> SymbolLayer? {
delegate?.carPlayManager(self, waypointSymbolLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
}


public func carPlayNavigationViewControllerWillDismiss(_ carPlayNavigationViewController: CarPlayNavigationViewController,
byCanceling canceled: Bool) {
Expand Down
46 changes: 46 additions & 0 deletions Sources/MapboxNavigation/CarPlayManagerDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,32 @@ public protocol CarPlayManagerDelegate: AnyObject, UnimplementedLogging, CarPlay
to parentViewController: UIViewController,
pointAnnotationManager: PointAnnotationManager)

/**
Asks the receiver to return a `SymbolLayer` for waypoint symbols, given an identifier and source.
This method is invoked any time waypoints are added or shown.

- parameter carPlayManager: The `CarPlayManager` object.
- parameter identifier: The `SymbolLayer` identifier.
- parameter sourceIdentifier: Identifier of the source, which contains the waypoint data that this method would style.
- returns: A `SymbolLayer` that the map applies to all waypoint symbols.
*/
func carPlayManager(_ carPlayManager: CarPlayManager,
waypointSymbolLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> SymbolLayer?

/**
Asks the receiver to return a `CircleLayer` for waypoints, given an identifier and source.
This method is invoked any time waypoints are added or shown.

- parameter carPlayManager: The `CarPlayManager` object.
- parameter identifier: The `CircleLayer` identifier.
- parameter sourceIdentifier: Identifier of the source, which contains the waypoint data that this method would style.
- returns: A `CircleLayer` that the map applies to all waypoints.
*/
func carPlayManager(_ carPlayManager: CarPlayManager,
waypointCircleLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> CircleLayer?

// MARK: Transitioning Between Templates

/**
Expand Down Expand Up @@ -692,6 +718,26 @@ public extension CarPlayManagerDelegate {
logUnimplemented(protocolType: CarPlayManagerDelegate.self, level: .debug)
}

/**
`UnimplementedLogging` prints a warning to standard output the first time this method is called.
*/
func carPlayManager(_ carPlayManager: CarPlayManager,
waypointSymbolLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> SymbolLayer? {
logUnimplemented(protocolType: CarPlayManagerDelegate.self, level: .debug)
return nil
}

/**
`UnimplementedLogging` prints a warning to standard output the first time this method is called.
*/
func carPlayManager(_ carPlayManager: CarPlayManager,
waypointCircleLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> CircleLayer? {
logUnimplemented(protocolType: CarPlayManagerDelegate.self, level: .debug)
return nil
}

/**
`UnimplementedLogging` prints a warning to standard output the first time this method is called.
*/
Expand Down
16 changes: 16 additions & 0 deletions Sources/MapboxNavigation/CarPlayNavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,22 @@ extension CarPlayNavigationViewController: NavigationServiceDelegate {

extension CarPlayNavigationViewController: NavigationMapViewDelegate {

public func navigationMapView(_ navigationMapView: NavigationMapView,
waypointCircleLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> CircleLayer? {
delegate?.carPlayNavigationViewController(self,
waypointCircleLayerWithIdentifier: identifier,
sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView,
waypointSymbolLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> SymbolLayer? {
delegate?.carPlayNavigationViewController(self,
waypointSymbolLayerWithIdentifier: identifier,
sourceIdentifier: sourceIdentifier)
}

public func navigationMapView(_ navigationMapView: NavigationMapView,
didAdd finalDestinationAnnotation: PointAnnotation,
pointAnnotationManager: PointAnnotationManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,34 @@ public protocol CarPlayNavigationViewControllerDelegate: AnyObject, Unimplemente
func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController,
routeLineLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> LineLayer?


/**
Asks the receiver to return a `SymbolLayer` for waypoint symbols, given an identifier and source.
This method is invoked any time waypoints are added or shown.

- parameter carPlayNavigationViewController: The `CarPlayNavigationViewController` object.
- parameter identifier: The `SymbolLayer` identifier.
- parameter sourceIdentifier: Identifier of the source, which contains the waypoint data that this method would style.
- returns: A `SymbolLayer` that the map applies to all waypoint symbols.
*/
func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController,
waypointSymbolLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> SymbolLayer?

/**
Asks the receiver to return a `CircleLayer` for waypoints, given an identifier and source.
This method is invoked any time waypoints are added or shown.

- parameter carPlayNavigationViewController: The `CarPlayNavigationViewController` object.
- parameter identifier: The `CircleLayer` identifier.
- parameter sourceIdentifier: Identifier of the source, which contains the waypoint data that this method would style.
- returns: A `CircleLayer` that the map applies to all waypoints.
*/
func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController,
waypointCircleLayerWithIdentifier identifier: String,
sourceIdentifier: String) -> CircleLayer?

/**
Asks the receiver to return a `LineLayer` for the casing layer that surrounds route line,
given a layer identifier and a source identifier.
Expand Down

0 comments on commit cb93c46

Please sign in to comment.