예제 #1
0
 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();
 }
예제 #2
0
 public FlyoverMapViewController(
     Flyover flyover,
     MKMapType mapType = MKMapType.Satellite,
     FlyoverCameraConfiguration configuration = null)
 {
     if (configuration == null)
     {
         configuration = new FlyoverCameraConfiguration(FlyoverCameraConfigurationTheme.Default);
     }
     FlyoverMapView = new FlyoverMapView(mapType, configuration);
     Flyover        = flyover;
     FlyoverMapView.Start(flyover);
 }
        public static bool NearlyEquals(this Flyover lhs, Flyover rhs)
        {
            if (rhs == null ||
                !lhs.Coordinate.IsValid() ||
                !rhs.Coordinate.IsValid())
            {
                return(false);
            }
            double factor = 1000.0;

            return(Math.Round(lhs.Coordinate.Latitude * factor) == Math.Round(rhs.Coordinate.Latitude * factor) &&
                   Math.Round(lhs.Coordinate.Longitude * factor) == Math.Round(rhs.Coordinate.Longitude * factor));
        }
예제 #4
0
 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);
     }
 }
예제 #5
0
 public void Start(Flyover flyover)
 {
     UserInteractionEnabled = false;
     FlyoverCamera.Start(flyover);
 }