Skip to content

Commit dc9f1e9

Browse files
author
Bobby Sudekum
authored
Merge pull request #1523 from mapbox/optionally-return
Allow locationFor(styleManager:) to optionally return location
2 parents 503900a + 2b40927 commit dc9f1e9

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes to the Mapbox Navigation SDK for iOS
22

3+
## master
4+
5+
* `StyleManager.locationFor(styleManager:)` now allows for an optional CLLocation to be returned. [#1523](https://github.com/mapbox/mapbox-navigation-ios/pull/1523)
6+
37
## v0.18.1 (June 19, 2018)
48

59
### Packaging

MapboxNavigation/NavigationViewController.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -608,16 +608,14 @@ extension NavigationViewController: TunnelIntersectionManagerDelegate {
608608

609609
extension NavigationViewController: StyleManagerDelegate {
610610

611-
public func locationFor(styleManager: StyleManager) -> CLLocation {
612-
guard let location = routeController.location else {
613-
if let coordinate = routeController.routeProgress.route.coordinates?.first {
614-
return CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude)
615-
} else {
616-
return CLLocation()
617-
}
611+
public func locationFor(styleManager: StyleManager) -> CLLocation? {
612+
if let location = routeController.location {
613+
return location
614+
} else if let firstCoord = routeController.routeProgress.route.coordinates?.first {
615+
return CLLocation(latitude: firstCoord.latitude, longitude: firstCoord.longitude)
616+
} else {
617+
return nil
618618
}
619-
620-
return location
621619
}
622620

623621
public func styleManager(_ styleManager: StyleManager, didApply style: Style) {

MapboxNavigation/StyleManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public protocol StyleManagerDelegate: NSObjectProtocol {
99
/**
1010
Asks the delegate for a location to use when calculating sunset and sunrise.
1111
*/
12-
@objc func locationFor(styleManager: StyleManager) -> CLLocation
12+
@objc func locationFor(styleManager: StyleManager) -> CLLocation?
1313

1414
/**
1515
Informs the delegate that a style was applied.

MapboxNavigationTests/NavigationViewControllerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class NavigationViewControllerTests: XCTestCase {
210210
}
211211

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

MapboxNavigationTests/StyleManagerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ extension StyleManagerTests: StyleManagerDelegate {
7979
func styleManagerDidRefreshAppearance(_ styleManager: StyleManager) { }
8080
func styleManager(_ styleManager: StyleManager, didApply style: Style) { }
8181

82-
func locationFor(styleManager: StyleManager) -> CLLocation {
82+
func locationFor(styleManager: StyleManager) -> CLLocation? {
8383
return location
8484
}
8585
}

0 commit comments

Comments
 (0)