From e8b29be79e5391dea7383ff69d9712ade7ca100d Mon Sep 17 00:00:00 2001 From: ClemensF Date: Sat, 29 Sep 2012 15:03:59 +0200 Subject: [PATCH] Set AffectsRender flag on MapPanel.ViewportPosition property, fixed Map.ZoomMap method. --- MapControl/Map.cs | 8 +++++++- MapControl/MapPanel.cs | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/MapControl/Map.cs b/MapControl/Map.cs index edbba0ba..03c7f87f 100644 --- a/MapControl/Map.cs +++ b/MapControl/Map.cs @@ -405,6 +405,7 @@ namespace MapControl UpdateTransform(); } + ResetTransformOrigin(); TranslateMap(translation); } @@ -414,8 +415,13 @@ namespace MapControl /// public void ZoomMap(Point origin, double zoomLevel) { - SetTransformOrigin(origin); + double targetZoomLebel = TargetZoomLevel; TargetZoomLevel = zoomLevel; + + if (TargetZoomLevel != targetZoomLebel) // TargetZoomLevel might be coerced + { + SetTransformOrigin(origin); + } } /// diff --git a/MapControl/MapPanel.cs b/MapControl/MapPanel.cs index 03a3c564..0beba283 100644 --- a/MapControl/MapPanel.cs +++ b/MapControl/MapPanel.cs @@ -22,7 +22,7 @@ namespace MapControl private static readonly DependencyPropertyKey ViewportPositionPropertyKey = DependencyProperty.RegisterAttachedReadOnly( "ViewportPosition", typeof(Point?), typeof(MapPanel), - new FrameworkPropertyMetadata(ViewportPositionPropertyChanged)); + new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender, ViewportPositionPropertyChanged)); public static readonly DependencyProperty ViewportPositionProperty = ViewportPositionPropertyKey.DependencyProperty; @@ -93,15 +93,13 @@ namespace MapControl protected virtual void OnViewportChanged() { - Map parentMap = ParentMap; - foreach (UIElement element in InternalChildren) { Location location = GetLocation(element); if (location != null) { - SetViewportPosition(element, parentMap, location); + SetViewportPosition(element, ParentMap, location); } } }