-
Notifications
You must be signed in to change notification settings - Fork 313
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
Navigation camera viewport API. #2826
Conversation
13e87df
to
9c8f2b7
Compare
95e1936
to
a7e26cf
Compare
4ab3cab
to
92e7897
Compare
f0853c7
to
f4ede64
Compare
7ae6b7b
to
861f66f
Compare
861f66f
to
6faf76a
Compare
335fda5
to
0d079f9
Compare
*/ | ||
open func updatePreferredFrameRate(for routeProgress: RouteProgress) { | ||
guard tracksUserCourse else { return } | ||
public func updatePreferredFrameRate(for routeProgress: RouteProgress) { |
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.
I thought that was supposed to be fixed as part of #2643?
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.
Thank you. This looks good.
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.
I think we should try to get some more certainty on #2826 (comment) and #2826 (comment) before landing, but otherwise the code looks to be in good shape.
…ngleDiffWhenSmoothing`, which allow to control `NavigationCamera` behavior.
/** | ||
Controls the distance on route after the current maneuver to include in the frame. | ||
|
||
Defaults to `100.0` meters. | ||
*/ | ||
public var distanceToFrameAfterManeuver: CLLocationDistance = 100.0 | ||
|
||
/** | ||
Controls how much the bearing can deviate from the location's bearing, in degrees. | ||
|
||
In case if set, the `bearing` property of `CameraOptions` during active guidance navigation | ||
won't exactly reflect the bearing returned by the location, but will also be affected by the | ||
direction to the upcoming framed geometry, to maximize the viewable area. | ||
|
||
Defaults to `20.0` degrees. | ||
*/ | ||
public var maximumBearingSmoothingAngle: CLLocationDirection? = 20.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 per our discussion with @d-prukop distanceToFrameAfterManeuver
and maximumBearingSmoothingAngle
were made publicly available to provide more control over default camera behavior. There are several other properties, which are exposed in Mapbox Navigation for Android, but haven't made their way into main
branch yet (and not yet present on iOS). We can add those in scope of tail-work. iOS implementation also doesn't use boolean flags to control usage of such properties (to simplify API), instead certain parameters provided as optionals.
Delegate, which is used to notify `NavigationCamera` regarding upcoming `CameraOptions` | ||
related changes. | ||
*/ | ||
public var delegate: ViewportDataSourceDelegate? |
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.
@MaximAlien Should we use weak
here? I see a possible retain loop
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.
Good catch, will be addressed in another PR.
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.
By the way, SwiftLint produces a warning for such issues.
@@ -116,7 +122,6 @@ extension ViewController { | |||
let branchNames = branchEdgeIdentifiers.flatMap { edgeNames(identifier: $0) } | |||
statusString += " at \(branchNames.joined(separator: ", "))" | |||
} | |||
print(statusString) |
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 print statement was intentional: otherwise, all the electronic horizon work above is for naught. Ideally there would be some UI associated with this output, but a print statement was more expedient at the time.
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.
Fixed in ca8be54.
Description
NavigationCamera
viewport APIs bring the ability to control camera related behavior, which is specific for navigation (mostly free-drive and active guidance navigation).NavigationCamera
API introduces such components:NavigationCamera
class, which works as a manager for all camera related operations (allows to move camera to following, overview and idle states).ViewportDataSource
protocol.NavigationViewportDataSource
class, which conforms toViewportDataSource
and listens to location changes in free drive and active guidance modes and preparesCameraOptions
. This class preparesCameraOptions
for both iOS and CarPlay, as they're different. Can be overridden by the end user to provide custom data source.CameraView
class, which allows to runUIViewPropertyAnimator
animations. Will be removed when such feature appears in Maps SDK.CameraStateTransition
protocol.NavigationCameraStateTransition
class, which conforms toCameraStateTransition
and provides set of specific animated transitions. Can be overridden by the end user.Current PR also contains an attempt to decouple location related APIs (e.g.
UserCourseView
) and camera related APIs inNavigationMapView
, this leads to removal/replacement of certain properties (defaultAltitude
,zoomedOutMotorwayAltitude
etc).Example application with custom camera implementation can be found here: mapbox/mapbox-navigation-ios-examples#92.
/cc @mapbox/navigation-ios @d-prukop
Initial results
camera_maneuver_behavior_building_highlighting.mov
navigation_camera_zoom_out_behavior.mov
overview_camera_behavior.mov
transitions_behavior.mov
car_play_behavior.mov
Known issues
https://github.com/mapbox/mapbox-maps-ios-internal/issues/600Recenter/overview button doesn't work on CarPlay. #2892CameraOptions are incorrect during active guidance navigation on CarPlay. #2891Route preview on CarPlay doesn't correctly show selected route. #2890Unable to zoom-in to current location if CarPlay example was opened independently. #2889