diff --git a/CHANGELOG.md b/CHANGELOG.md index fbc108a6f97..9cc9a350b8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ * Fixed an issue where popped window doesn't get updated in appearance when style changes on phone. ([#3954](https://github.com/mapbox/mapbox-navigation-ios/pull/3954)) * Fixed an issue where detailed feedback items don't change color in different style. ([#3954](https://github.com/mapbox/mapbox-navigation-ios/pull/3954)) * Update method deprecation for `HistoryRecording` protocol. Static methods are now preferred over instance ones. ([#3960](https://github.com/mapbox/mapbox-navigation-ios/pull/3960)) +* Fixed an issue where `UserPuckCourseView` is drawn in incorrect position if its location is outside of the bounds of `MapView`. ([#3988](https://github.com/mapbox/mapbox-navigation-ios/pull/3988)) ## v2.5.1 diff --git a/Sources/MapboxNavigation/NavigationMapView.swift b/Sources/MapboxNavigation/NavigationMapView.swift index 949586416d8..143ef65e81a 100755 --- a/Sources/MapboxNavigation/NavigationMapView.swift +++ b/Sources/MapboxNavigation/NavigationMapView.swift @@ -1083,6 +1083,15 @@ open class NavigationMapView: UIView { from previousLocation: CLLocation? = nil, to location: CLLocation, animated: Bool = false) { + // If the point is outside of the bounds of `MapView` - hide user course view. + let point = mapView.mapboxMap.point(for: location.coordinate) + if point.x == -1.0 && point.y == -1.0 { + userCourseView.isHidden = true + return + } else { + userCourseView.isHidden = false + } + if let previousLocation = previousLocation { let point = mapView.mapboxMap.point(for: previousLocation.coordinate) userCourseView.center = point