From dc48c5712e9bf43982a2f72a373ab300c33078ce Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Wed, 6 Jul 2022 18:29:52 -0400 Subject: [PATCH] Hide user course view in case if current user location coordinate point is invalid. (#3988) Cherry-picked 8e7485dc5aeba6ae4391f58f57f2ddbbf86a0a73. --- CHANGELOG.md | 1 + Sources/MapboxNavigation/NavigationMapView.swift | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c5c1bc6aaa..e75450252c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ * 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 a bug which sometimes caused the crash when new continuous alternatives arrive. ([#3986](https://github.com/mapbox/mapbox-navigation-ios/pull/3986)) +* 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 248f4d4c825..4f8e3c38f3b 100755 --- a/Sources/MapboxNavigation/NavigationMapView.swift +++ b/Sources/MapboxNavigation/NavigationMapView.swift @@ -1084,6 +1084,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