react-native-mapbox-navigation
react-native-mapbox-navigation copied to clipboard
Can we stop the navigation manually before reaching to final destination?
There is not a way to stop navigation imperatively via a ref on the MapboxNavigation
component. You can accomplish this currently by removing the MapboxNavigation
component and mounting a new one.
@rossmartin So you don't think there would be a way to utilize these methods mapbox provides?
There is not a way to stop navigation imperatively via a ref on the
MapboxNavigation
component. You can accomplish this currently by removing theMapboxNavigation
component and mounting a new one.
Thanks @rossmartin i also noticed one thing that onCancelNavigation does not stop the navigation, can we also add this as well in enhancement please.
To stop navigation add the following to the navigationViewControllerDidDismiss
function
navigationViewController.navigationService.stop()
navigationViewController.dismiss(animated: true, completion: nil)
func navigationViewControllerDidDismiss(_ navigationViewController: NavigationViewController, byCanceling canceled: Bool) {
if (!canceled) {
return;
}
// add
navigationViewController.navigationService.stop()
navigationViewController.dismiss(animated: true, completion: nil)
onCancelNavigation?(["message": ""]);
}
@MaganAnkur @rossmartin
Reference: https://github.com/mapbox/mapbox-navigation-ios/issues/2201#issuecomment-693539539
Has anyone figured this out? I can't seem to get around it. Find it odd that the "x" button doesn't just stop it...