Skip to content

Commit

Permalink
Merge pull request #2387 from mapbox/vk-puck-location-on-resize
Browse files Browse the repository at this point in the history
Puck Location fix
  • Loading branch information
Udumft authored Jun 11, 2020
2 parents cd48910 + 27f4afa commit 5888534
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions MapboxNavigation/NavigationMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -340,16 +340,20 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate {
return
}

let centerUserCourseView = { [weak self] in
guard let point = self?.convert(location.coordinate, toPointTo: self) else { return }
self?.userCourseView.center = point
}

if tracksUserCourse {
centerUserCourseView()

let newCamera = camera ?? MGLMapCamera(lookingAtCenter: location.coordinate, altitude: altitude, pitch: 45, heading: location.course)
let function: CAMediaTimingFunction? = animated ? CAMediaTimingFunction(name: .linear) : nil
setCamera(newCamera, withDuration: duration, animationTimingFunction: function, completionHandler: nil)
} else {
// Animate course view updates in overview mode
UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear], animations: { [weak self] in
guard let point = self?.convert(location.coordinate, toPointTo: self) else { return }
self?.userCourseView.center = point
})
UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear], animations: centerUserCourseView)
}

userCourseView.update(location: location, pitch: self.camera.pitch, direction: direction, animated: animated, tracksUserCourse: tracksUserCourse)
Expand Down

0 comments on commit 5888534

Please sign in to comment.