public override void ViewDidLoad() { base.ViewDidLoad(); map = new MGLMapView(View.Bounds); map.AutoresizingMask = new UIViewAutoresizing(); map.WeakDelegate = this; View.AddSubview(map); map.ShowsUserLocation = true; map.SetUserTrackingMode(MGLUserTrackingMode.Follow, true); UILongPressGestureRecognizer longPress = new UILongPressGestureRecognizer(DidLongPressOnMap); map.AddGestureRecognizer(longPress); MBWaypoint[] ways = new MBWaypoint[2]; ways[0] = new MBWaypoint(new CLLocationCoordinate2D(45.622073, -73.824223), -1, "origin"); ways[1] = new MBWaypoint(new CLLocationCoordinate2D(45.626764, -73.825742), -1, "destination"); MBNavigationRouteOptions options = new MBNavigationRouteOptions(ways, MBDirectionsProfileIdentifier.Automobile); MBDirections.SharedDirections.CalculateDirectionsWithOptions(options, (way, routes, error) => { if (routes.Length == 0 || routes == null) { string errorMessage = "No routes found"; if (error != null) { errorMessage = error.LocalizedDescription; } var alert = UIAlertController.Create("Error", errorMessage, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Dismiss", UIAlertActionStyle.Cancel, null)); PresentViewController(alert, true, null); } else { MBRoute route = routes[0]; MBNavigationService navigationService = new MBNavigationService(route, MBDirections.SharedDirections, null, null, MBNavigationSimulationOptions.Always, null); //MBNavigationOptions navigationOptions = new MBNavigationOptions(null, navigationService, null, null, null); MBNavigationViewController navigationViewController = new MBNavigationViewController(route, null); PresentViewController(navigationViewController, true, null); } }); }