3

I'm working on a route navigation app that draws a route on the map. Now I've found out that whenever I'm using a Mapbox simulator the route steps aren't being updated. For example: Just after starting the navigation you get 'Turn right after 100 meters'. After the simulator turns right you never see the next step even though the simulator continues to execute.

I tried hardcoding waypoints into the code. This results in a working route. I've routes set up on the database. I wanted to verify these routes by verifying the JSON's of both versions. I've found out that the JSON's are pretty similar so I do not expect the problem to be buried within there.

I've tried setting several breakpoints in the code to isolate where the code fails. I have come to the conclusion that route steps aren't being updated because the code returns as a result of a guard statement. Our function: updateStep() is called from out a NavigationViewController. It calls to the function which is defined in a separate file in which the guard statement returns.

I've tried updating Mapbox to 0.38.0 (was 0.37.0).

func updateStep(routeProgress: RouteProgress, altStep: RouteStep? = nil) {
        let routeStep = altStep ?? routeProgress.currentLegProgress.currentStep
        print ("RouteProgressService - altStep: \(altStep)")
        let steps = routeProgress.currentLeg.steps
        guard let newStepIndex = steps.index(of: routeStep), newStepIndex > currentStepIndex  else {
            print("return")
            return
        }

I expect the code to not return and conti nee to execute the function. Though the guard statement returns because the newer routeStep is not greater than the currentStepIndex.

Frank
  • 99
  • 3
  • 14

0 Answers0