maplibre / maplibre-navigation-ios

MapLibre Navigation SDK for iOS
Other
36 stars 29 forks source link

Make sure the puck stays on the route while animating the map #59

Closed boldtrn closed 3 months ago

boldtrn commented 3 months ago

This is a followup for #27. While the puck stays on the route line while manually panning the map, it still veers of when running animations (like zoom to the whole route). For these kinds of animations, implementers can now call the enableFrameByFrameCourseViewTracking from outside of the NavigationMapView to fix special cases like this.

michaelkirk commented 3 months ago

To be sure I understand: This change by itself won't fix anything, but by making the method public, others can call it when they do things that would otherwise break the animation.

Is that correct? That seems reasonable if so.

But I'm a little confused by your "zoom to the whole route" example. I'm assuming you mean the codepath that calls RouteMapViewController.toggleOverview(_) - right?

It actually already calls this (previously internal) internal method:

@objc func toggleOverview(_ sender: Any) {
    self.mapView.enableFrameByFrameCourseViewTracking(for: 3) // <-- ALREADY CALLED
    if let coordinates = routeController.routeProgress.route.coordinates, let userLocation = routeController.locationManager.location?.coordinate {
        self.mapView.setOverheadCameraView(from: userLocation, along: coordinates, for: self.overheadInsets)
    }
    self.isInOverviewMode = true
}

I haven't really been able to reproduce the puck going off the rails with the overview button, but I did just now file #61, which I think is a separate issue.

boldtrn commented 3 months ago

To be sure I understand: This change by itself won't fix anything, but by making the method public, others can call it when they do things that would otherwise break the animation.

Yes correct.

But I'm a little confused by your "zoom to the whole route" example.

Yeah, it's just an arbitrary example. In our app we zoom out to show a set of multiple points and the user location. Essentially any camera animation would need something like this. And if you are using something that is not yet included in the NavigationMapView (or RouteMapViewController), you can't use the method yet, so I think it makes sense to make it available.