mapbox / mapbox/mapbox-navigation-ios

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

Open
#4,567 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Swift
Stars
918
Forks
326
Avg merge
1h 16m
Merged PRs (30d)
3

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with NavigationRouteOptions, profileIdentifier set to .cycling, and Directions.shared.calculate as shown in the report. Compare the cycling path with the working walking and automobile cases; done means cycling routes calculate successfully and NavigationViewController presents and starts simulated navigation without the annotations error.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.