-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sticky course view tracking and persistent content inset #2047
Conversation
|
||
if overviewing { | ||
let padding = UIEdgeInsets(top: 40, left: 40, bottom: 40, right: 40) | ||
contentInsets += padding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Max MBRouteLineWidthByZoomLevel should be accounted for.
UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: { | ||
self.userCourseView?.center = self.convert(location.coordinate, toPointTo: self) | ||
userCourseView?.center = userAnchorPoint | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reprises part of #1732. I take it #1732 (comment) is no longer a concern because the puck’s on-screen position is a fixed value now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. The position is fixed unless frame by frame tracking is enabled which is needed when content insets or device orientation changes.
if overviewing { | ||
let courseView = mapView.userCourseView != nil ? mapView.userCourseView!.bounds.midX : 0 | ||
let routeLineWidths = MBRouteLineWidthByZoomLevel.compactMap { $0.value.constantValue as? Int } | ||
let maxRouteLineWidth = CGFloat(routeLineWidths.max() ?? 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resulting zoom level is the only one that matters, right?
Apparently this issue regresses |
a6edd1e
to
e79599c
Compare
The CarPlay preview is reverted and should behave exactly as before, |
@@ -587,8 +587,7 @@ extension CarPlayManager: CPMapTemplateDelegate { | |||
topDownCamera.pitch = 0 | |||
mapView.setCamera(topDownCamera, animated: false) | |||
|
|||
let padding = NavigationMapView.defaultPadding + mapView.safeArea | |||
mapView.showcase([route], padding: padding) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
e01d000
to
e9450fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things to add to the changelog:
- Fixed an issue where the user puck moved around onscreen while tracking the user’s location.
- Fixed an issue where the user puck briefly moved away from the route line as the user completed a turn.
|
||
if !tracksUserCourse { | ||
mapView.setContentInset(overviewContentInsets(), animated: false) | ||
mapView.fit(to: navigationService.route, facing: 0, padding: .zero, animated: false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now if the user pans, disabling course tracking but without entering overview mode, the map will revert to course tracking once the navigation bar goes away. I guess that’s OK but somewhat unexpected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. We probably need a flag isOverviewing
here similar to RouteMapViewController.
Panning around is currently not possible either with course tracking on/off nor overviewing (navigation bar popping in triggers viewSafeAreaInsetsDidChange() which in turn, fits the camera to the route).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JThramer pointed out that this is actually pretty fortuitous. There isn’t a Resume or Recenter button like in NavigationViewController, and there’s no location tracking button like during the CarPlay browsing activity, so this code path is actually the most convenient way to get back into course tracking mode. Otherwise, the user has to tap the Overview button and tap the location tracking button after that.
currentCamera.pitch = 0 | ||
currentCamera.heading = 0 | ||
|
||
let newCamera = camera(currentCamera, fitting: line, edgePadding: padding) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to calling cameraThatFits(_:direction:edgePadding:)
, since we’re forcing the pitch to be 0° anyways.
insets += NavigationMapView.courseViewMinimumInsets | ||
|
||
let routeLineWidths = MBRouteLineWidthByZoomLevel.compactMap { $0.value.constantValue as? Int } | ||
insets += UIEdgeInsets(floatLiteral: Double(routeLineWidths.max() ?? 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 As noted in #2047 (comment), this is rather conservative considering that only one zoom level is active at a given time. But we don‘t have ready access to the evaluated expression (unlike if we were using GL JS), and this method also gets called before calculating a camera rather than after, so choosing the right width isn’t worth the hassle. In practice, it would only be a few extra points on each side at most.
f6e640b
to
0326e45
Compare
work in progress
Fix CarPlay map fits to previewed route when returning to main map from custom template #2030 CarPlay map fitting(already fixed in Fix route preview in CarPlay #2022)This PR brings back the course tracking similar to the default in MGLMapView where the puck and camera are synchronized which is really noticeable when simulating faster than 1×.
cc @1ec5 @JThramer