Skip to content
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

Fix puck location during navigation #82

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Patrick-Kladek
Copy link
Contributor

@Patrick-Kladek Patrick-Kladek commented Jul 12, 2024

Description

Warning: do not merge right away, this contains changes from #76 which needs to be merged first!

For some reason, the user puck was centered on the map. This reduced the visible road ahead and made navigation quite bad.

Open Tasks

  • Fix user puck position during navigation

Infos for Reviewer

The trick was to create a padding close to the region where the user puck is positioned. This padding is then used when the camera is set for the MapView.

Here is a recording from our app (SwiftUI), while starting the navigation and transitioning between overhead mode. It's not perfect yet (the overhead move is not fully visible, need to investigate further) but it's a lot better than what we currently have. There is no workaround needed to get the puck down and it is also butter smooth.

Bildschirmaufnahme.Simulator.mov

@michaelkirk
Copy link
Collaborator

Is this about #80 or something else?

@Patrick-Kladek
Copy link
Contributor Author

Yes, I wasn't aware that you created an issue already

@Patrick-Kladek Patrick-Kladek marked this pull request as ready for review July 15, 2024 07:38
@hactar hactar requested a review from michaelkirk July 17, 2024 18:15
@hactar
Copy link
Collaborator

hactar commented Jul 17, 2024

@michaelkirk could you take a look at this? You recently did some "puck work" so I'd assume you're better suited then me. :)

Copy link
Collaborator

@michaelkirk michaelkirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the slow review! I'm not very familiar with the puck placement code, so I mostly just have questions at this point.

Example/example/SceneDelegate.swift Show resolved Hide resolved
@@ -347,20 +355,18 @@ open class NavigationMapView: MLNMapView, UIGestureRecognizerDelegate {
return
}

if !self.tracksUserCourse || self.userAnchorPoint != userCourseView?.center ?? self.userAnchorPoint {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this boolean check go away? (TBH I'm not sure I understand what it was doing in the first place)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check was in place so centering the puck only happened if it was not centred already (optimisation maybe). As the map is moving during navigation we need to position the puck anyway, thats why I removed it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map stops moving if the user pans. Does that matter?

Is this change required for the "position camera in bottom 1/3" of the screen work, or is this some bonus cleanup?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's the point, if I move the map I want to look at a specific point. The puck is continuously updated and I can tap the "Resume" button to get typical navigation camera movement back.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why did it change in this PR? Again, I can't tell if you are doing random cleanup to make things nicer, or if this is required due to other changes you made to get the puck to appear in the bottom 1/3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did remove this because it makes no difference. This if clause resolved to true in all scenarios I've tested. I guess this was relevant when we manually posited the userCourseView.center to the screen's center. Now that this is gone it's not necessary anymore.

@@ -567,6 +568,7 @@ extension RouteMapViewController: NavigationViewDelegate {
if userTrackingMode == .none, !self.isInOverviewMode {
self.navigationView.wayNameView.isHidden = true
}
mapView.userTrackingMode = userTrackingMode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because otherwise I would need to set the userTracking mode in startNavigation(). This way is more reliable.

If you look at the whole function there seems to be something missing, userTrackingMode is read from the mapView, then updated but never written back to the mapView, so it's basically unused. I suspect this was the intent in the first place but could have changed in a previous PR (maybe on accident).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not understanding why this would need to change to address the "position camera in bottom 1/3" of the screen logic. Is it required or is this some bonus work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done as a precaution to sync the tracking mode when navigating. Why else would we read, then modify the trackingMode but not assign it to the mapView? You could even say it fixes something a previous PR missed, otherwise we could remove this function altogether as it does nothing.

Bildschirmfoto 2024-08-01 um 14 22 26

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not saying you're wrong, but to review your code I need to understand what you are trying to do.

You said this pr is about positioning the puck in the bottom 1/3 of the viewport.

But this change is about something else, right? Did you observe a broken behavior with this? Or is this just about fixing code that "looked wrong"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are bothered by this line and want me to remove it because you think it's unnecessary then please say that. I've explained to you twice why I think we need this.

@michaelkirk
Copy link
Collaborator

michaelkirk commented Aug 1, 2024 via email

…n-ios into user-puck-positioning

# Conflicts:
#	MapboxNavigation/NavigationMapView.swift
@hactar hactar self-requested a review October 16, 2024 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants