mapbox / mapbox/mapbox-maps-ios

SwiftUI RouteProgress support

Open
#2,316 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged feature :green_apple:
Dominant language
Swift
Stars
601
Forks
196
PR merge metrics
No merged PRs in 30d

Description

## New Feature

I am building a custom navigation UI and have been able to accomplish this pretty nicely using SwiftUI. However there just is no smooth way to handle RouteProgress updates.

This is currently how I'm handling showing the route and the progress but it is nowhere near as smooth as the drop-in NavigationViewController. The line annotation doesn't stay aligned with the Puck and is mostly updating too early and ahead or behind and too late.

# Extracting remaining route coordinates
`private func updateRouteLines(with routeProgress: RouteProgress) {
var coordinates = routeProgress.currentLegProgress.currentStepProgress.remainingStepCoordinates()

for step in routeProgress.currentLegProgress.remainingSteps {
if let stepCoordinates = step.shape?.coordinates {
coordinates.append(contentsOf: stepCoordinates)
}
}

// Get coordinates for all remaining legs
for leg in routeProgress.remainingLegs {
for step in leg.steps {
if let stepCoordinates = step.shape?.coordinates {
coordinates.append(contentsOf: stepCoordinates)
}
}
}

remainingStepRouteCoordinates = coordinates
}`

# Annotation
`PolylineAnnotationGroup {
PolylineAnnotation(lineCoordinates: remainingStepRouteCoordinates)
.lineColor(.init(UIColor.white))
.lineWidth(8)
}
.lineCap(.round)
.slot(.middle)
`

## Why
I can't use the NavigationViewController due to custom UI/UX requirements. This would unlock SwiftUI navigation capabilities for Mapbox developers looking to use SwiftUI.

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 reviewing the SwiftUI RouteProgress flow described in the issue, including remainingStepCoordinates(), remainingLegs, and the PolylineAnnotationGroup/PolylineAnnotation usage. Compare this with the drop-in NavigationViewController behavior; done means SwiftUI users can receive smooth RouteProgress updates while the route line stays aligned with the Puck.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.