Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide portions of the route that the user has passed #2377

Merged
merged 27 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cf0b63e
Remove addCongestion
captainbarbosa Jun 15, 2020
25fcd74
More testing
captainbarbosa Jun 16, 2020
1d5bb1c
Vanish route line
captainbarbosa Jun 17, 2020
ad51cae
First refactor
captainbarbosa Jun 17, 2020
48c2800
Add route casing back
captainbarbosa Jun 17, 2020
055bd3e
Fix vanishing route casing
captainbarbosa Jun 17, 2020
61c3278
Update NavigationMapView.swift
captainbarbosa Jun 18, 2020
b108792
Rename SourceIdentifier.route
captainbarbosa Jun 18, 2020
5cfe0b5
Rename StyleLayerIdentifier constants
captainbarbosa Jun 18, 2020
6d2d234
Implement mainRouteStyleLayerWithIdentifier delegate
captainbarbosa Jun 18, 2020
5d3a00c
Implement mainRouteCasingStyleLayerWithIdentifier delegate
captainbarbosa Jun 18, 2020
e12a3e5
Implement alternateRouteStyleLayerWithIdentifier delegate
captainbarbosa Jun 19, 2020
c6477f7
Implement alternateRouteCasingStyleLayerWithIdentifier delegate
captainbarbosa Jun 19, 2020
b0295a0
Remove routeStyleLayerWithIdentifier/routeCasingStyleLayerWithIdentif…
captainbarbosa Jun 19, 2020
d07ac38
Fill out docs
captainbarbosa Jun 19, 2020
99f2c4f
Refactor, make vanishing color customizable
captainbarbosa Jun 19, 2020
8440ff4
Update DayStyle.swift
captainbarbosa Jun 19, 2020
5007d44
Update CHANGELOG.md
captainbarbosa Jun 19, 2020
a758912
Little refactoring
captainbarbosa Jun 22, 2020
27a102d
Make vanishing route opt-in
captainbarbosa Jun 23, 2020
d82f746
Merge branch 'release-v1.0-pre-registry' into nb/vanishing-route-line
captainbarbosa Jun 24, 2020
db5f27d
Merge pull request #2418 from mapbox/nb/vanishing-route-line-2
captainbarbosa Jun 24, 2020
f8915e2
Update NavigationMapView.swift
captainbarbosa Jun 24, 2020
fc8574f
Update CHANGELOG.md
captainbarbosa Jun 24, 2020
32e0d32
Change property name from vanishingRouteColor → traversedRouteColor
captainbarbosa Jun 24, 2020
3da9452
Rename fadesRouteDuringNavigation → routeLineTracksTraversal
captainbarbosa Jun 24, 2020
86b6862
Final feedback edits
captainbarbosa Jun 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
* Fixed an issue where spoken and visual instructions sometimes omitted the cardinal direction after a route number in the United States. ([valhalla/valhalla#1917](https://github.com/valhalla/valhalla/pull/1917))
* A spoken instruction about an exit ramp no longer specifies the side of the road if the ramp branches off the slow lane (on the right side in regions that drive on the right). ([valhalla/valhalla#1990](https://github.com/valhalla/valhalla/pull/1990))

## Map

* Removed `NavigationMapViewDelegate.navigationMapView(_:routeStyleLayerWithIdentifier:source:)`, `NavigationMapViewDelegate.navigationMapView(_:routeCasingStyleLayerWithIdentifier:source:)` in favor of four new delegate methods to customize the route styling ([#2377](https://github.com/mapbox/mapbox-navigation-ios/pull/2377)):
captainbarbosa marked this conversation as resolved.
Show resolved Hide resolved
* `NavigationMapViewDelegate.navigationMapView(_:mainRouteStyleLayerWithIdentifier:source:)` to style the main route.
* `NavigationMapViewDelegate.navigationMapView(_:mainRouteCasingStyleLayerWithIdentifier:source:)` to style the casing of the main route.
* `NavigationMapViewDelegate.navigationMapView(_:alternativeRouteStyleLayerWithIdentifier:source:)` to style alternative routes.
* `NavigationMapViewDelegate.navigationMapView(_:alternativeRouteCasingStyleLayerWithIdentifier:source:)` to style the casing of alternative routes.
* Added the ability for the route line to disappear as the puck travels along a route during turn-by-turn navigation. ([#2377](https://github.com/mapbox/mapbox-navigation-ios/pull/2377))
* Fixed an issue where the casing for the main route would not overlap alternative routes. ([#2377](https://github.com/mapbox/mapbox-navigation-ios/pull/2377))

## v0.40.0

### Packaging
Expand Down
2 changes: 2 additions & 0 deletions MapboxNavigation/DayStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extension UIColor {
class var defaultRouteLayer: UIColor { get { return #colorLiteral(red: 0.337254902, green: 0.6588235294, blue: 0.9843137255, alpha: 1) } }
class var defaultAlternateLine: UIColor { get { return #colorLiteral(red: 0.6, green: 0.6, blue: 0.6, alpha: 1) } }
class var defaultAlternateLineCasing: UIColor { get { return #colorLiteral(red: 0.5019607843, green: 0.4980392157, blue: 0.5019607843, alpha: 1) } }
class var defaultTraversedRouteColor: UIColor { get { return #colorLiteral(red: 1, green: 1, blue: 1, alpha: 0) } }
class var defaultManeuverArrowStroke: UIColor { get { return .defaultRouteLayer } }
class var defaultManeuverArrow: UIColor { get { return #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1) } }

Expand Down Expand Up @@ -116,6 +117,7 @@ open class DayStyle: Style {
NavigationMapView.appearance().maneuverArrowStrokeColor = .defaultManeuverArrowStroke
NavigationMapView.appearance().routeAlternateColor = .defaultAlternateLine
NavigationMapView.appearance().routeCasingColor = .defaultRouteCasing
NavigationMapView.appearance().traversedRouteColor = .defaultTraversedRouteColor
NavigationMapView.appearance().trafficHeavyColor = .trafficHeavy
NavigationMapView.appearance().trafficLowColor = .trafficLow
NavigationMapView.appearance().trafficModerateColor = .trafficModerate
Expand Down
367 changes: 296 additions & 71 deletions MapboxNavigation/NavigationMapView.swift

Large diffs are not rendered by default.

79 changes: 58 additions & 21 deletions MapboxNavigation/NavigationMapViewDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,46 @@ import MapboxCoreNavigation
The `NavigationMapViewDelegate` provides methods for configuring the NavigationMapView, as well as responding to events triggered by the NavigationMapView.
*/
public protocol NavigationMapViewDelegate: class, UnimplementedLogging {

/**
Asks the receiver to return an MGLStyleLayer for routes, given an identifier and source.
Asks the receiver to return an MGLStyleLayer for the main route line, given an identifier and source.
This method is invoked when the map view loads and any time routes are added.
- parameter mapView: The NavigationMapView.
- parameter identifier: The style identifier.
- parameter source: The Layer source containing the route data that this method would style.
- returns: An MGLStyleLayer that the map applies to all routes.
*/
func navigationMapView(_ mapView: NavigationMapView, routeStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?
- parameter source: The source containing the route data that this method would style.
- returns: An MGLStyleLayer that is applied to the main route line.
*/
func navigationMapView(_ mapView: NavigationMapView, mainRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

/**
Asks the receiver to return an MGLStyleLayer for the casing layer that surrounds main route line, given an identifier and source.
This method is invoked when the map view loads and any time routes are added.
- parameter mapView: The NavigationMapView.
- parameter identifier: The style identifier.
- parameter source: The source containing the route data that this method would style.
- returns: An MGLStyleLayer that is applied as a casing around the main route line.
*/
func navigationMapView(_ mapView: NavigationMapView, mainRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

/**
Asks the receiver to return an MGLStyleLayer for the alternative route lines, given an identifier and source.
This method is invoked when the map view loads and any time routes are added.
- parameter mapView: The NavigationMapView.
- parameter identifier: The style identifier.
- parameter source: The source containing the route data that this method would style.
- returns: An MGLStyleLayer that is applied to alternative routes.
*/
func navigationMapView(_ mapView: NavigationMapView, alternativeRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

/**
Asks the receiver to return an MGLStyleLayer for the casing layer that surrounds alternative route lines, given an identifier and source.
This method is invoked when the map view loads and any time routes are added.
- parameter mapView: The NavigationMapView.
- parameter identifier: The style identifier.
- parameter source: The source containing the route data that this method would style.
- returns: An MGLStyleLayer that is applied as a casing around alternative route lines.
*/
func navigationMapView(_ mapView: NavigationMapView, alternateRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

/**
Asks the receiver to return an MGLStyleLayer for waypoints, given an identifier and source.
Expand All @@ -36,17 +67,6 @@ public protocol NavigationMapViewDelegate: class, UnimplementedLogging {
*/
func navigationMapView(_ mapView: NavigationMapView, waypointSymbolStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

/**
Asks the receiver to return an MGLStyleLayer for route casings, given an identifier and source.
This method is invoked when the map view loads and anytime routes are added.
- note: Specify a casing to ensure good contrast between the route line and the underlying map layers.
- parameter mapView: The NavigationMapView.
- parameter identifier: The style identifier.
- parameter source: The Layer source containing the route data that this method would style.
- returns: An MGLStyleLayer that the map applies to the route.
*/
func navigationMapView(_ mapView: NavigationMapView, routeCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

/**
Tells the receiver that the user has selected a route by interacting with the map view.
- parameter mapView: The NavigationMapView.
Expand Down Expand Up @@ -98,34 +118,51 @@ public protocol NavigationMapViewDelegate: class, UnimplementedLogging {
}

public extension NavigationMapViewDelegate {

/**
`UnimplementedLogging` prints a warning to standard output the first time this method is called.
*/
func navigationMapView(_ mapView: NavigationMapView, routeStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
func navigationMapView(_ mapView: NavigationMapView, mainRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
logUnimplemented(protocolType: NavigationMapViewDelegate.self, level: .debug)
return nil
}

/**
`UnimplementedLogging` prints a warning to standard output the first time this method is called.
*/
func navigationMapView(_ mapView: NavigationMapView, waypointStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
func navigationMapView(_ mapView: NavigationMapView, mainRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
logUnimplemented(protocolType: NavigationMapViewDelegate.self, level: .debug)
return nil
}

/**
`UnimplementedLogging` prints a warning to standard output the first time this method is called.
*/
func navigationMapView(_ mapView: NavigationMapView, alternativeRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
logUnimplemented(protocolType: NavigationMapViewDelegate.self, level: .debug)
return nil
}

/**
`UnimplementedLogging` prints a warning to standard output the first time this method is called.
*/
func navigationMapView(_ mapView: NavigationMapView, alternateRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
logUnimplemented(protocolType: NavigationMapViewDelegate.self, level: .debug)
return nil
}

/**
`UnimplementedLogging` prints a warning to standard output the first time this method is called.
*/
func navigationMapView(_ mapView: NavigationMapView, waypointSymbolStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
func navigationMapView(_ mapView: NavigationMapView, waypointStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
logUnimplemented(protocolType: NavigationMapViewDelegate.self, level: .debug)
return nil
}

/**
`UnimplementedLogging` prints a warning to standard output the first time this method is called.
*/
func navigationMapView(_ mapView: NavigationMapView, routeCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
func navigationMapView(_ mapView: NavigationMapView, waypointSymbolStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
logUnimplemented(protocolType: NavigationMapViewDelegate.self, level: .debug)
return nil
}
Expand Down
19 changes: 14 additions & 5 deletions MapboxNavigation/NavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,21 @@ open class NavigationViewController: UIViewController, NavigationStatusPresenter

//MARK: - RouteMapViewControllerDelegate
extension NavigationViewController: RouteMapViewControllerDelegate {
public func navigationMapView(_ mapView: NavigationMapView, routeCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
return delegate?.navigationViewController(self, routeCasingStyleLayerWithIdentifier: identifier, source: source)

public func navigationMapView(_ mapView: NavigationMapView, mainRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
return delegate?.navigationViewController(self, mainRouteStyleLayerWithIdentifier: identifier, source: source)
}

public func navigationMapView(_ mapView: NavigationMapView, routeStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
return delegate?.navigationViewController(self, routeStyleLayerWithIdentifier: identifier, source: source)

public func navigationMapView(_ mapView: NavigationMapView, mainRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
return delegate?.navigationViewController(self, mainRouteCasingStyleLayerWithIdentifier: identifier, source: source)
}

public func navigationMapView(_ mapView: NavigationMapView, alternativeRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
return delegate?.navigationViewController(self, alternativeRouteStyleLayerWithIdentifier: identifier, source: source)
}

public func navigationMapView(_ mapView: NavigationMapView, alternateRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
return delegate?.navigationViewController(self, alternateRouteCasingStyleLayerWithIdentifier: identifier, source: source)
}

public func navigationMapView(_ mapView: NavigationMapView, didSelect route: Route) {
Expand Down
58 changes: 40 additions & 18 deletions MapboxNavigation/NavigationViewControllerDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,35 @@ public protocol NavigationViewControllerDelegate: VisualInstructionDelegate{
- parameter error: An error raised during the process of obtaining a new route.
*/
func navigationViewController(_ navigationViewController: NavigationViewController, didFailToRerouteWith error: Error)



/**
Returns an `MGLStyleLayer` that determines the appearance of the route line.
Returns an `MGLStyleLayer` that determines the appearance of the main route line.

If this method is unimplemented, the navigation view controller’s map view draws the route line using an `MGLLineStyleLayer`.
*/
func navigationViewController(_ navigationViewController: NavigationViewController, routeStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?
*/
func navigationViewController(_ navigationViewController: NavigationViewController, mainRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

/**
Returns an `MGLStyleLayer` that determines the appearance of the route line’s casing.

If this method is unimplemented, the navigation view controller’s map view draws the route line’s casing using an `MGLLineStyleLayer` whose width is greater than that of the style layer returned by `navigationViewController(_:routeStyleLayerWithIdentifier:source:)`.
*/
func navigationViewController(_ navigationViewController: NavigationViewController, routeCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?
Returns an `MGLStyleLayer` that determines the appearance of the casing around the main route line.

If this method is unimplemented, the navigation view controller’s map view draws the casing for the main route line using an `MGLLineStyleLayer`.
*/
func navigationViewController(_ navigationViewController: NavigationViewController, mainRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

/**
Returns an `MGLStyleLayer` that determines the appearance of alternative route lines.

If this method is unimplemented, the navigation view controller’s map view draws the alternative route lines using an `MGLLineStyleLayer`.
*/
func navigationViewController(_ navigationViewController: NavigationViewController, alternativeRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

/**
Returns an `MGLStyleLayer` that determines the appearance of the casing around the alternative route lines.

If this method is unimplemented, the navigation view controller’s map view draws the casing for the alternative route lines using an `MGLLineStyleLayer`.
*/
func navigationViewController(_ navigationViewController: NavigationViewController, alternateRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer?

/**
Returns an `MGLShape` that represents the path of the route line.
Expand Down Expand Up @@ -243,19 +258,26 @@ public extension NavigationViewControllerDelegate {
func navigationViewController(_ navigationViewController: NavigationViewController, didFailToRerouteWith error: Error) {
logUnimplemented(protocolType: NavigationViewControllerDelegate.self, level: .debug)
}

/**
`UnimplementedLogging` prints a warning to standard output the first time this method is called.
*/
func navigationViewController(_ navigationViewController: NavigationViewController, routeStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
func navigationViewController(_ navigationViewController: NavigationViewController, mainRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
logUnimplemented(protocolType: NavigationViewControllerDelegate.self, level: .debug)
return nil
}

/**
`UnimplementedLogging` prints a warning to standard output the first time this method is called.
*/
func navigationViewController(_ navigationViewController: NavigationViewController, routeCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {

func navigationViewController(_ navigationViewController: NavigationViewController, mainRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
logUnimplemented(protocolType: NavigationViewControllerDelegate.self, level: .debug)
return nil
}

func navigationViewController(_ navigationViewController: NavigationViewController, alternativeRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
logUnimplemented(protocolType: NavigationViewControllerDelegate.self, level: .debug)
return nil
}

func navigationViewController(_ navigationViewController: NavigationViewController, alternateRouteCasingStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
logUnimplemented(protocolType: NavigationViewControllerDelegate.self, level: .debug)
return nil
}
Expand Down
Loading