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

Allow locationFor(styleManager:) to optionally return location #1523

Merged
merged 3 commits into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes to the Mapbox Navigation SDK for iOS

## master

* `StyleManager.locationFor(styleManager:)` now allows for an optional CLLocation to be returned. [#1523](https://github.com/mapbox/mapbox-navigation-ios/pull/1523)

## v0.18.1 (June 19, 2018)

### Packaging
Expand Down
16 changes: 7 additions & 9 deletions MapboxNavigation/NavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -608,16 +608,14 @@ extension NavigationViewController: TunnelIntersectionManagerDelegate {

extension NavigationViewController: StyleManagerDelegate {

public func locationFor(styleManager: StyleManager) -> CLLocation {
guard let location = routeController.location else {
if let coordinate = routeController.routeProgress.route.coordinates?.first {
return CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude)
} else {
return CLLocation()
}
public func locationFor(styleManager: StyleManager) -> CLLocation? {
if let location = routeController.location {
return location
} else if let firstCoord = routeController.routeProgress.route.coordinates?.first {
return CLLocation(latitude: firstCoord.latitude, longitude: firstCoord.longitude)
} else {
return nil
}

return location
}

public func styleManager(_ styleManager: StyleManager, didApply style: Style) {
Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation/StyleManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public protocol StyleManagerDelegate: NSObjectProtocol {
/**
Asks the delegate for a location to use when calculating sunset and sunrise.
*/
@objc func locationFor(styleManager: StyleManager) -> CLLocation
@objc func locationFor(styleManager: StyleManager) -> CLLocation?

/**
Informs the delegate that a style was applied.
Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigationTests/NavigationViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class NavigationViewControllerTests: XCTestCase {
}

extension NavigationViewControllerTests: NavigationViewControllerDelegate, StyleManagerDelegate {
func locationFor(styleManager: StyleManager) -> CLLocation {
func locationFor(styleManager: StyleManager) -> CLLocation? {
return dependencies.poi.first!
}

Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigationTests/StyleManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ extension StyleManagerTests: StyleManagerDelegate {
func styleManagerDidRefreshAppearance(_ styleManager: StyleManager) { }
func styleManager(_ styleManager: StyleManager, didApply style: Style) { }

func locationFor(styleManager: StyleManager) -> CLLocation {
func locationFor(styleManager: StyleManager) -> CLLocation? {
return location
}
}