react-native-mapbox-navigation icon indicating copy to clipboard operation
react-native-mapbox-navigation copied to clipboard

Can we stop the navigation manually before reaching to final destination?

Open MaganAnkur opened this issue 3 years ago • 5 comments

MaganAnkur avatar Apr 08 '21 20:04 MaganAnkur

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 avatar Apr 19 '21 23:04 rossmartin

@rossmartin So you don't think there would be a way to utilize these methods mapbox provides? Screen Shot 2021-04-22 at 4 20 34 PM

thomaskbird avatar Apr 22 '21 20:04 thomaskbird

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.

Thanks @rossmartin i also noticed one thing that onCancelNavigation does not stop the navigation, can we also add this as well in enhancement please.

MaganAnkur avatar Apr 28 '21 06:04 MaganAnkur

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

engelzero avatar May 03 '21 04:05 engelzero

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...

younusmahmood avatar Feb 27 '22 04:02 younusmahmood