Skip to content

Fix route preview in CarPlay - #2022

Merged
JThramer merged 6 commits into
masterfrom
fred/carplay-preview
Mar 15, 2019
Merged

JThramer merged 6 commits into
masterfrom
fred/carplay-preview

Conversation

@frederoni

Copy link
Copy Markdown
Contributor

This PR attempts to fix the padding when previewing a route in CarPlay which wasn't always fully visible before.

There is at least one issue we need to fix before this PR can land.
To reproduce: Preview a route, go back to the initial screen. The route is selected according to isOverviewingRoute and accounted for in map view’s content inset, but the route is not drawn on the map. Should the route be selected or deselected?

cc @1ec5

@1ec5

1ec5 commented Mar 14, 2019

Copy link
Copy Markdown
Contributor

To reproduce: Preview a route, go back to the initial screen. The route is selected according to isOverviewingRoute and accounted for in map view’s content inset, but the route is not drawn on the map. Should the route be selected or deselected?

This issue only reproduces in the example application when returning to the main map from the favorites list. When returning from the search template, the map immediately tilts and enables user tracking mode, thanks to this special case:

let isCorrectType = type(of: template) == CPSearchTemplate.self || type(of: template) == CPMapTemplate.self
guard let interface = interfaceController, let top = interface.topTemplate,
type(of: top) == CPSearchTemplate.self || interface.templates.count == 1,
isCorrectType,
let carPlayMapViewController = carPlayMapViewController else { return }
if type(of: template) == CPSearchTemplate.self {
carPlayMapViewController.isOverviewingRoutes = false
}
carPlayMapViewController.resetCamera(animated: false)

@1ec5

1ec5 commented Mar 14, 2019 •

Copy link
Copy Markdown
Contributor

Tracking the case of returning to the main map as tail work in #2030.

if let userCourseView = mapView.userCourseView {
let midX = userCourseView.bounds.midX
let midY = userCourseView.bounds.midY
edgePadding += UIEdgeInsets(top: midY, left: midX, bottom: midY, right: midX)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This if block seems to be ensuring that the course view is always fully visible on the map. But about the waypoints? And if we’re previewing a route where the route line might extend in all directions from the user’s current location, then this alone won’t ensure that the whole route fits on the map. We have logic elsewhere about resetting or fitting the camera. Maybe we should reuse it instead of trying to reimplement some of it via edge insets.

…where "fly to current location" wasn't working when coming from favorites or nav-end.
@JThramer

Copy link
Copy Markdown
Contributor

@1ec5

1ec5 commented Mar 14, 2019

Copy link
Copy Markdown
Contributor

That fixes #2030 as well, then.

@1ec5 1ec5 added this to the v0.30.0 milestone Mar 14, 2019
@JThramer
JThramer marked this pull request as ready for review March 14, 2019 22:46
Comment thread MapboxNavigation/CarPlayManager.swift Resolved
Comment thread MapboxNavigation/CarPlayManager.swift Resolved
Comment thread MapboxNavigation/CarPlayManager.swift Resolved
@JThramer

Copy link
Copy Markdown
Contributor

Behavior remains unchanged from demo video posted earlier.

@1ec5 1ec5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remember to add a changelog entry.

@frederoni frederoni mentioned this pull request Mar 15, 2019
2 of 5 tasks
@JThramer
JThramer merged commit 50a0672 into master Mar 15, 2019
@JThramer
JThramer deleted the fred/carplay-preview branch March 15, 2019 18:14
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