Skip to content

Commit a915d1c

Browse files
authored
Add delegates to NavigationViewController that allow to detect taps on waypoint and continuous alternatives. (#4175)
1 parent e9b9ea9 commit a915d1c

File tree

5 files changed

+148
-69
lines changed

5 files changed

+148
-69
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* Additional parameters were added to `FloatingButton.rounded(image:selectedImage:size:type:imageEdgeInsets:cornerRadius)` to be able to provide button type, button image edge insets and corner radius. ([#4060](https://github.com/mapbox/mapbox-navigation-ios/pull/4060), [#4157](https://github.com/mapbox/mapbox-navigation-ios/pull/4157))
2929
* `IndexedRouteResponse` is now the preferred way for setting up routing information for navigation. `NavigationViewController`, `MapboxNavigationService`, `Router` and `RoutingProvider` are updated to accomodate this change. ([#4127](https://github.com/mapbox/mapbox-navigation-ios/pull/4127))
3030
* `FloatingButton` no longer contains corner radius shadow, border is applied instead. ([#4060](https://github.com/mapbox/mapbox-navigation-ios/pull/4060))
31+
* Added the `NavigationViewControllerDelegate.navigationViewController(_:didSelect:)` and `NavigationViewControllerDelegate.navigationViewController(_:didSelect:)` methods that allow selection of the waypoint and continuous alternative. ([#4175](https://github.com/mapbox/mapbox-navigation-ios/pull/4175))
3132

3233
## v2.8.0
3334

MapboxNavigation.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
8AC40920279918930075248E /* NavigationViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC4091F279918930075248E /* NavigationViewDelegate.swift */; };
268268
8AC5070728D3D925005D45EB /* CameraModeFloatingButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC5070628D3D925005D45EB /* CameraModeFloatingButton.swift */; };
269269
8AC5070928D3D930005D45EB /* CameraModeFloatingButtonDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC5070828D3D930005D45EB /* CameraModeFloatingButtonDelegate.swift */; };
270+
8AC5070C28D3F6E3005D45EB /* NavigationViewController+NavigationMapViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC5070B28D3F6E3005D45EB /* NavigationViewController+NavigationMapViewDelegate.swift */; };
270271
8AC85EA428628E4F003F8FC8 /* UIDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC85EA328628E4F003F8FC8 /* UIDevice.swift */; };
271272
8ACF0AAA2706394A00F30423 /* CPInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ACF0AA92706394A00F30423 /* CPInterfaceController.swift */; };
272273
8AD12F4C26C193560008AE55 /* LeaksTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AD12F4826C193520008AE55 /* LeaksTests.swift */; };
@@ -869,6 +870,7 @@
869870
8AC4091F279918930075248E /* NavigationViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationViewDelegate.swift; sourceTree = "<group>"; };
870871
8AC5070628D3D925005D45EB /* CameraModeFloatingButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraModeFloatingButton.swift; sourceTree = "<group>"; };
871872
8AC5070828D3D930005D45EB /* CameraModeFloatingButtonDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraModeFloatingButtonDelegate.swift; sourceTree = "<group>"; };
873+
8AC5070B28D3F6E3005D45EB /* NavigationViewController+NavigationMapViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NavigationViewController+NavigationMapViewDelegate.swift"; sourceTree = "<group>"; };
872874
8AC85EA328628E4F003F8FC8 /* UIDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDevice.swift; sourceTree = "<group>"; };
873875
8ACF0AA92706394A00F30423 /* CPInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPInterfaceController.swift; sourceTree = "<group>"; };
874876
8AD12F4326C191080008AE55 /* Snapshot++.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Snapshot++.swift"; sourceTree = "<group>"; };
@@ -1985,6 +1987,7 @@
19851987
8A11FEEF27A3514C00285B6F /* CPRouteChoice.swift */,
19861988
8AD220AA27C091EE000734A5 /* Solar.swift */,
19871989
8AD220AE27C09544000734A5 /* Date.swift */,
1990+
8AC5070B28D3F6E3005D45EB /* NavigationViewController+NavigationMapViewDelegate.swift */,
19881991
);
19891992
name = Extensions;
19901993
sourceTree = "<group>";
@@ -2796,6 +2799,7 @@
27962799
C57491DF1FACC42F006F97BC /* CGPoint.swift in Sources */,
27972800
8A50A3C426EC09FB00894A8E /* FeedbackViewController.swift in Sources */,
27982801
B4E19C47268114840011581F /* NavigationLocationProvider.swift in Sources */,
2802+
8AC5070C28D3F6E3005D45EB /* NavigationViewController+NavigationMapViewDelegate.swift in Sources */,
27992803
16C2A421211526EE00FE6E68 /* CarPlayManager.swift in Sources */,
28002804
8AA0386327F7B3F50007BD2D /* BottomBannerViewControllerDelegate.swift in Sources */,
28012805
8D53136B20653FA20044891E /* ExitView.swift in Sources */,
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import MapboxMaps
2+
import MapboxDirections
3+
import MapboxCoreNavigation
4+
5+
// MARK: NavigationMapViewDelegate methods
6+
7+
extension NavigationViewController: NavigationMapViewDelegate {
8+
9+
public func navigationMapView(_ navigationMapView: NavigationMapView,
10+
routeLineLayerWithIdentifier identifier: String,
11+
sourceIdentifier: String) -> LineLayer? {
12+
delegate?.navigationViewController(self,
13+
routeLineLayerWithIdentifier: identifier,
14+
sourceIdentifier: sourceIdentifier)
15+
}
16+
17+
public func navigationMapView(_ navigationMapView: NavigationMapView,
18+
routeCasingLineLayerWithIdentifier identifier: String,
19+
sourceIdentifier: String) -> LineLayer? {
20+
delegate?.navigationViewController(self,
21+
routeCasingLineLayerWithIdentifier: identifier,
22+
sourceIdentifier: sourceIdentifier)
23+
}
24+
25+
public func navigationMapView(_ navigationMapView: NavigationMapView,
26+
routeRestrictedAreasLineLayerWithIdentifier identifier: String,
27+
sourceIdentifier: String) -> LineLayer? {
28+
delegate?.navigationViewController(self,
29+
routeRestrictedAreasLineLayerWithIdentifier: identifier,
30+
sourceIdentifier: sourceIdentifier)
31+
}
32+
33+
public func navigationMapView(_ navigationMapView: NavigationMapView,
34+
waypointCircleLayerWithIdentifier identifier: String,
35+
sourceIdentifier: String) -> CircleLayer? {
36+
delegate?.navigationViewController(self,
37+
waypointCircleLayerWithIdentifier: identifier,
38+
sourceIdentifier: sourceIdentifier)
39+
}
40+
41+
public func navigationMapView(_ navigationMapView: NavigationMapView,
42+
waypointSymbolLayerWithIdentifier identifier: String,
43+
sourceIdentifier: String) -> SymbolLayer? {
44+
delegate?.navigationViewController(self,
45+
waypointSymbolLayerWithIdentifier: identifier,
46+
sourceIdentifier: sourceIdentifier)
47+
}
48+
49+
public func navigationMapView(_ navigationMapView: NavigationMapView,
50+
shapeFor waypoints: [Waypoint],
51+
legIndex: Int) -> FeatureCollection? {
52+
delegate?.navigationViewController(self,
53+
shapeFor: waypoints,
54+
legIndex: legIndex)
55+
}
56+
57+
public func navigationMapView(_ navigationMapView: NavigationMapView,
58+
didAdd finalDestinationAnnotation: PointAnnotation,
59+
pointAnnotationManager: PointAnnotationManager) {
60+
delegate?.navigationViewController(self,
61+
didAdd: finalDestinationAnnotation,
62+
pointAnnotationManager: pointAnnotationManager)
63+
}
64+
65+
public func navigationMapView(_ navigationMapView: NavigationMapView,
66+
didSelect waypoint: Waypoint) {
67+
delegate?.navigationViewController(self,
68+
didSelect: waypoint)
69+
}
70+
71+
public func navigationMapView(_ navigationMapView: NavigationMapView,
72+
didSelect continuousAlternative: AlternativeRoute) {
73+
router.updateRoute(with: continuousAlternative.indexedRouteResponse,
74+
routeOptions: nil,
75+
completion: nil)
76+
77+
delegate?.navigationViewController(self,
78+
didSelect: continuousAlternative)
79+
}
80+
}

Sources/MapboxNavigation/NavigationViewController.swift

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,42 +1317,3 @@ extension NavigationViewController: CarPlayConnectionObserver {
13171317
}
13181318
}
13191319
}
1320-
1321-
// MARK: NavigationMapViewDelegate methods
1322-
1323-
extension NavigationViewController: NavigationMapViewDelegate {
1324-
1325-
public func navigationMapView(_ navigationMapView: NavigationMapView, routeLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? {
1326-
delegate?.navigationViewController(self, routeLineLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
1327-
}
1328-
1329-
public func navigationMapView(_ navigationMapView: NavigationMapView, routeCasingLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? {
1330-
delegate?.navigationViewController(self, routeCasingLineLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
1331-
}
1332-
1333-
public func navigationMapView(_ navigationMapView: NavigationMapView, routeRestrictedAreasLineLayerWithIdentifier identifier: String, sourceIdentifier: String) -> LineLayer? {
1334-
delegate?.navigationViewController(self, routeRestrictedAreasLineLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
1335-
}
1336-
1337-
public func navigationMapView(_ navigationMapView: NavigationMapView, waypointCircleLayerWithIdentifier identifier: String, sourceIdentifier: String) -> CircleLayer? {
1338-
delegate?.navigationViewController(self, waypointCircleLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
1339-
}
1340-
1341-
public func navigationMapView(_ navigationMapView: NavigationMapView, waypointSymbolLayerWithIdentifier identifier: String, sourceIdentifier: String) -> SymbolLayer? {
1342-
delegate?.navigationViewController(self, waypointSymbolLayerWithIdentifier: identifier, sourceIdentifier: sourceIdentifier)
1343-
}
1344-
1345-
public func navigationMapView(_ navigationMapView: NavigationMapView, shapeFor waypoints: [Waypoint], legIndex: Int) -> FeatureCollection? {
1346-
delegate?.navigationViewController(self, shapeFor: waypoints, legIndex: legIndex)
1347-
}
1348-
1349-
public func navigationMapView(_ navigationMapView: NavigationMapView, didAdd finalDestinationAnnotation: PointAnnotation, pointAnnotationManager: PointAnnotationManager) {
1350-
delegate?.navigationViewController(self, didAdd: finalDestinationAnnotation, pointAnnotationManager: pointAnnotationManager)
1351-
}
1352-
1353-
public func navigationMapView(_ navigationMapView: NavigationMapView, didSelect continuousAlternative: AlternativeRoute) {
1354-
router.updateRoute(with: continuousAlternative.indexedRouteResponse,
1355-
routeOptions: nil,
1356-
completion: nil)
1357-
}
1358-
}

0 commit comments

Comments
 (0)