Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to start a route in NavigationViewController with .cycling ProfileIdentifier #4567

Open
njm2015 opened this issue Nov 16, 2023 · 0 comments
Labels
bug Something isn’t working

Comments

@njm2015
Copy link

njm2015 commented Nov 16, 2023

Mapbox Navigation SDK version

2.17.0

Steps to reproduce

Set the profileIdentifier on the NavigationRouteOptions object to .cycling. The following code snippet was originally pulled from this docs page and modified in my own project slightly in order to work.

let routeOptions = NavigationRouteOptions(waypoints: [
    Waypoint(coordinate: CLLocationCoordinate2D(latitude: 37.77766, longitude: -122.43199)),
    Waypoint(coordinate: CLLocationCoordinate2D(latitude: 37.77609, longitude: -122.43292)),
    Waypoint(coordinate: CLLocationCoordinate2D(latitude: 37.77536, longitude: -122.43494)),
])

// error is here - works when using .walking, .automobile, or .automobileAvoidingTraffic
routeOptions.profileIdentifier = .cycling

Directions.shared.calculate(routeOptions) { [weak self] (session, result) in
    switch result {
    case .failure(let error):
        print(error.localizedDescription)
    case .success(let response):
        guard let route = response.routes?.first, let strongSelf = self else {
            return
        }
        
        let navigationService = MapboxNavigationService(route: route, routeIndex: 0, routeOptions: routeOptions, simulating: .always)
        let navigationOptions = NavigationOptions(navigationService: navigationService)
        let navigationViewController = NavigationViewController(for: route, routeIndex: 0, routeOptions: routeOptions, navigationOptions: navigationOptions)
        navigationViewController.delegate = strongSelf
        
        strongSelf.present(navigationViewController, animated: true, completion: nil)
    }
}

Expected behavior

The NavigationViewController is expected to present and start simulating route navigation.

Actual behavior

Log in the console:

The operation couldn’t be completed. annotations value must be one of duration, distance, speed, maxspeed, congestion

Is this a one-time issue or a repeatable issue?

repeatable

@njm2015 njm2015 added the bug Something isn’t working label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

No branches or pull requests

1 participant