قالب وردپرس درنا توس
Home / IOS Development / swift – Mapbox Navigation on iOS with my mapView controller

swift – Mapbox Navigation on iOS with my mapView controller



This might be a little helpful: you can easily add an observer for changes in route progress:

  NotificationCenter.default.addObserver (self,
selector: #selector (progressDidChange (alert :)),
name: .routeControllerProgressDidChange,
object: navigationService.router)

You need a navigation service with your route by creating it as

  let navigationService = MapboxNavigationService (route: route)

The function progressDidChange can do something like:

  @objc func progressDidChange (notification: NSNotification) {
watch la routeProgress = alert.user info? [RouteControllerNotificationUserInfoKey.routeProgressKey] like? RouteProgress,
let location = alert.user info? [RouteControllerNotificationUserInfoKey.locationKey] like? CLLocation else {
return
}

// you have all the information you probably need in routeProgress, f.E.
la secondsRemaining = routeProgress.currentLegProgress.currentStepProgress.durationRemaining

...
}


Source link