Open
Description
hi there,
I have implemented Mapbox navigation in my project. I need to navigate a path with multiple waypoints, and I want to detect when the user arrives at the waypoint and Navigation is ended. However, it's not calling delegate functions when the user arrives and navigation is ended.
But I have noticed that
Below is code to start turn by turn navigation
guard let navigationRoutes else {
self.parentView().showAutoDismissAlert(title: "Error!", message: "Navigation route not available!")
return
}
let navigationOptions = NavigationOptions(
mapboxNavigation: mapboxNavigation,
voiceController: mapboxNavigationProvider.routeVoiceController,
eventsManager: mapboxNavigationProvider.eventsManager(),
predictiveCacheManager: mapboxNavigationProvider.predictiveCacheManager
)
navigationViewController = NavigationViewController(
navigationRoutes: navigationRoutes,
navigationOptions: navigationOptions
)
guard let navigationViewController else {
self.parentView().showAutoDismissAlert(title: "Error!", message: "Navigation route not available!")
return
}
navigationViewController.showsEndOfRouteFeedback = false
navigationViewController.delegate = self
navigationViewController.modalPresentationStyle = .fullScreen
isNavigationStarted = true
present(navigationViewController, animated: true)
Delegate functions
extension TripNavigationViewController: NavigationViewControllerDelegate, UINavigationControllerDelegate{
func navigationViewController(_ navigationViewController: NavigationViewController, didArriveAt waypoint: Waypoint, after legIndex: Int) -> Bool {
print("Arrived at waypoint: \(waypoint.name ?? "Unknown") (Leg Index: \(legIndex))")
DispatchQueue.main.async {
self.findNearbyStops()
}
return false
}
func navigationViewControllerDidDismiss(
_ navigationViewController: NavigationViewController,
byCanceling canceled: Bool
) {
DispatchQueue.main.async {
self.isNavigationStarted = !canceled
if canceled {
print("❌ Navigation was canceled by the user")
} else {
print("✅ Navigation has finished")
}
self.dismiss(animated: true, completion: nil)
}
}
}
I've been stuck on this for long and tried many solutions but nothing worked
MapboxNavigation 3.6.0
MapboxMaps 11.9.0
iOS 14.0+
Metadata
Metadata
Assignees
Labels
No labels