I'm using the HERE iOS SDK and I'm implementing a turn-by-turn navigation but method didUpdateManeuvers
of NMANavigationManagerDelegate
or any else is not called.
When I try to simulate move and use:
let source = NMARoutePositionSource(route: route.route)
NMAPositioningManager.sharedInstance().dataSource = source
all works fine, but when I simulate move through GPX
file or test in live, methods of delegate is not called...
My code:
class HereMapViewController: UIViewController {
@IBOutlet private weak var mapView: NMAMapView!
fileprivate var navigationManager = NMANavigationManager.sharedInstance()
var route : NMAMapRoute?
// MARK: - life cycle
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}
deinit {
navigationManager.stop()
}
// MARK: - private
private func setupUI() {
mapView.copyrightLogoPosition = .center
mapView.zoomLevel = 10
mapView.positionIndicator.isVisible = true
mapView.gestureDelegate = self
navigationManager.voicePackageMeasurementSystem = NMAMeasurementSystem.imperialUS
navigationManager.backgroundNavigationEnabled = true
navigationManager.isVoiceEnabled = true
navigationManager.delegate = self
setupRoute()
}
private func setupRoute() {
guard let mapRoute = route, let routeStart = mapRoute.route.start else {
return
}
let start = NMAGeoCoordinates(latitude: routeStart.navigablePosition.latitude,
longitude: routeStart.navigablePosition.longitude)
mapView.add(mapObject: mapRoute)
mapView.set(boundingBox: mapRoute.route.boundingBox!, animation: NMAMapAnimation.none)
startNavigation()
mapView.set(geoCenter: start, animation: .none)
}
private func startNavigation() {
guard let route = route else {
return
}
navigationManager.map = mapView
NMAPositioningManager.sharedInstance().dataSource = NMAHEREPositionSource()
navigationManager.startTurnByTurnNavigation(route.route)
navigationManager.mapTrackingEnabled = false
navigationManager.mapTrackingAutoZoomEnabled = false
navigationManager.mapTrackingOrientation = .dynamic
navigationManager.isSpeedWarningEnabled = true
}
}
//MARK: - NMANavigationManagerDelegate
extension HereMapViewController : NMANavigationManagerDelegate {
// Signifies that there is new instruction information available
func navigationManager(_ navigationManager: NMANavigationManager, didUpdateManeuvers currentManeuver: NMAManeuver?, _ nextManeuver: NMAManeuver?) {
print("didUpdateManeuvers")
}
// Signifies that the system has found a GPS signal
func navigationManagerDidFindPosition(_ navigationManager: NMANavigationManager) {
print("New position has been found")
}
func navigationManager(_ navigationManager: NMANavigationManager, didFindAlternateRoute routeResult: NMARouteResult) {
print("didFindAlternateRoute")
}
func navigationManager(_ navigationManager: NMANavigationManager, didUpdateRoute routeResult: NMARouteResult) {
print("didUpdateRoute")
}
}
//MARK: - NMAMapGestureDelegate
extension HereMapViewController : NMAMapGestureDelegate {
func mapView(_ mapView: NMAMapView, didReceiveTwoFingerPan translation: CGPoint, at location: CGPoint) {
navigationManager.mapTrackingAutoZoomEnabled = false
}
}
I want to track, when I should change manoeuvre or when I need to create a new route if user went the wrong way. I will be grateful for the help.