From 710edbbb0b8bac0925d97a91b6162c547da36b90 Mon Sep 17 00:00:00 2001 From: Bobby Sudekum Date: Thu, 22 Mar 2018 10:28:12 -0700 Subject: [PATCH] Fix center point (#1251) --- MapboxNavigation/NavigationMapView.swift | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/MapboxNavigation/NavigationMapView.swift b/MapboxNavigation/NavigationMapView.swift index f1b4bcfdbe1..57dd1a6ab59 100644 --- a/MapboxNavigation/NavigationMapView.swift +++ b/MapboxNavigation/NavigationMapView.swift @@ -178,12 +178,6 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate { if let location = userLocationForCourseTracking { updateCourseTracking(location: location, animated: true) } - - if let location = userLocationForCourseTracking, tracksUserCourse { - UIView.animate(withDuration: 1, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: { - self.userCourseView?.center = self.convert(location.coordinate, toPointTo: self) - }, completion: nil) - } } } @@ -348,7 +342,11 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate { let padding = UIEdgeInsets(top: point.y, left: point.x, bottom: bounds.height - point.y, right: bounds.width - point.x) let newCamera = MGLMapCamera(lookingAtCenter: location.coordinate, fromDistance: altitude, pitch: 45, heading: location.course) let function: CAMediaTimingFunction? = animated ? CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear) : nil - setCamera(newCamera, withDuration: duration, animationTimingFunction: function, edgePadding: padding, completionHandler: nil) + setCamera(newCamera, withDuration: duration, animationTimingFunction: function, edgePadding: padding, completionHandler: { + UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: { + self.userCourseView?.center = self.convert(location.coordinate, toPointTo: self) + }, completion: nil) + }) } else { UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: { self.userCourseView?.center = self.convert(location.coordinate, toPointTo: self)