private void PerformFlyover(Flyover flyover) { if (!flyover.Coordinate.IsValid()) { return; } if (_mapView == null) { return; } // Increase heading by heading step for _mapCamera _mapCamera.Heading += Configuration.HeadingStep; _mapCamera.Heading = _mapCamera.Heading % 360; // Initialize UIViewPropertyAnimator _animator = new UIViewPropertyAnimator( Configuration.Duration, Curve, animations: () => { _mapView.Camera = _mapCamera; }); // Add completion _animator?.SetCompletion((a) => { if (_flyover.NearlyEquals(flyover)) { PerformFlyover(flyover); } }); // Start animation _animator?.StartAnimation(); }
public void Start(Flyover flyover) { // Set flyover _flyover = flyover; if (UIApplication.SharedApplication.ApplicationState != UIApplicationState.Active) { // Return out of function return; } // Change state State = FlyoverCameraState.Started; // Stop current animation _animator?.ForceStopAnimation(); // Set center coordinate _mapCamera.CenterCoordinate = flyover.Coordinate; // Check if duration is zero or the current mapView camera // equals nearly the same to the current flyover if (new Flyover(_mapView.Camera).NearlyEquals(_flyover)) { // Simply perform flyover as we are still looking at the same coordinate PerformFlyover(flyover); } else if (Configuration.RegionChangeAnimation == RegionChangeAnimation.Animated && Configuration.Duration > 0) { // Apply StartAnimationMode animated // Initialize start animator var startAnimator = new UIViewPropertyAnimator( duration: Configuration.Duration, curve: Curve, animations: () => { _mapView.Camera = _mapCamera; }); // Add completion startAnimator.SetCompletion((x) => PerformFlyover(_flyover)); // Start animation startAnimator.StartAnimation(); } else { // No animation should be applied // Set MapView Camera to look at coordinate _mapView.Camera = _mapCamera; // Perform flyover PerformFlyover(_flyover); } }