/// <summary> /// Navigate to center and change resolution with animation /// </summary> /// <param name="center">New center to move to</param> /// <param name="resolution">New resolution to use</param> /// <param name="duration">Duration of animation in milliseconds</param> public void NavigateTo(Point center, double resolution, long duration = 300) { // Stop any old animation if there is one if (_animation != null) { _animation.Stop(false); _animation = null; } if (duration == 0) { _viewport.SetCenter(center); _viewport.SetResolution(resolution); Navigated?.Invoke(this, EventArgs.Empty); } else { var animations = new List <AnimationEntry>(); if (!_viewport.Center.Equals(center)) { var entry = new AnimationEntry( start: _viewport.Center, end: (ReadOnlyPoint)center, animationStart: 0, animationEnd: 1, easing: Easing.Linear, tick: CenterTick, final: CenterFinal ); animations.Add(entry); } if (_viewport.Resolution != resolution) { var entry = new AnimationEntry( start: _viewport.Resolution, end: resolution, animationStart: 0, animationEnd: 1, easing: Easing.Linear, tick: ResolutionTick, final: ResolutionFinal ); animations.Add(entry); } if (animations.Count == 0) { return; } _animation = new Animation(duration); _animation.Entries.AddRange(animations); _animation.Start(); } }
public void SetResolution(double resolution) { if (Map.ZoomLock) { return; } resolution = Limiter.LimitResolution(resolution, _viewport.Width, _viewport.Height, Map.Resolutions, Map.Envelope); _viewport.SetResolution(resolution); }
/// <summary> /// Navigate center of viewport to center of extent and change resolution /// </summary> /// <param name="extent">New extent for viewport to show</param> /// <param name="scaleMethod">Scale method to use to determin resolution</param> public void NavigateTo(BoundingBox extent, ScaleMethod scaleMethod = ScaleMethod.Fit) { if (extent == null) { return; } _viewport.SetResolution(ZoomHelper.DetermineResolution( extent.Width, extent.Height, _viewport.Width, _viewport.Height, scaleMethod)); _viewport.SetCenter(extent.Centroid); _map.RefreshData(_viewport.Extent, _viewport.Resolution, true); }
public static void Limit(IViewport viewport, ZoomMode zoomMode, MinMax zoomLimits, IReadOnlyList <double> mapResolutions, PanMode panMode, BoundingBox panLimits, BoundingBox mapEnvelope) { viewport.SetResolution(LimitResolution(viewport.Resolution, viewport.Width, viewport.Height, zoomMode, zoomLimits, mapResolutions, mapEnvelope)); LimitExtent(viewport, panMode, panLimits, mapEnvelope); }
/// <summary> /// Navigate center of viewport to center of extent and change resolution /// </summary> /// <param name="extent">New extent for viewport to show</param> /// <param name="scaleMethod">Scale method to use to determine resolution</param> public void NavigateTo(BoundingBox extent, ScaleMethod scaleMethod = ScaleMethod.Fit) { if (extent == null) { return; } var resolution = ZoomHelper.DetermineResolution( extent.Width, extent.Height, _viewport.Width, _viewport.Height, scaleMethod); _viewport.SetResolution(resolution); _viewport.SetCenter(extent.Centroid); Navigated?.Invoke(this, EventArgs.Empty); }
public void Limit(IViewport viewport, IReadOnlyList <double> mapResolutions, BoundingBox mapEnvelope) { viewport.SetResolution(LimitResolution(viewport.Resolution, viewport.Width, viewport.Height, mapResolutions, mapEnvelope)); LimitExtent(viewport, mapEnvelope); }
/// <summary> /// Change resolution of viewport /// </summary> /// <param name="resolution">New resolution to use</param> /// <param name="duration">Duration for animation in milliseconds.</param> /// <param name="easing">The type of easing function used to transform from begin tot end state</param> public void ZoomTo(double resolution, long duration = 0, Easing?easing = default) { _viewport.SetResolution(resolution, duration, easing); OnNavigated(duration, ChangeType.Discrete); }