diff --git a/MapControl/Shared/MapPath.cs b/MapControl/Shared/MapPath.cs index 2db8bee3..7d666b5b 100644 --- a/MapControl/Shared/MapPath.cs +++ b/MapControl/Shared/MapPath.cs @@ -4,13 +4,10 @@ #if WINUI using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Media; #elif UWP using Windows.UI.Xaml; -using Windows.UI.Xaml.Media; #else using System.Windows; -using System.Windows.Media; #endif namespace MapControl @@ -30,7 +27,7 @@ namespace MapControl /// /// Gets or sets a Location that is used as /// - either the origin point of a geometry specified in projected map coordinates (meters) - /// - or as an optional value to constrain the view position of MapPaths with multiple + /// - or as an optional anchor point to constrain the view position of MapPaths with multiple /// Locations (like MapPolyline or MapPolygon) to the visible map viewport, as done /// for elements where the MapPanel.Location property is set. /// @@ -73,16 +70,7 @@ namespace MapControl { if (parentMap != null && Location != null && Data != null) { - var matrix = parentMap.GetMapTransform(Location); - - if (Data.Transform is MatrixTransform transform) - { - transform.Matrix = matrix; - } - else - { - Data.Transform = new MatrixTransform { Matrix = matrix }; - } + SetMapTransform(parentMap.GetMapTransform(Location)); } MapPanel.SetLocation(this, Location); diff --git a/MapControl/WPF/MapPath.WPF.cs b/MapControl/WPF/MapPath.WPF.cs index 4ff6a6f3..3c75cf32 100644 --- a/MapControl/WPF/MapPath.WPF.cs +++ b/MapControl/WPF/MapPath.WPF.cs @@ -40,12 +40,23 @@ namespace MapControl } else { - data.Transform = new MatrixTransform(); path.UpdateData(); } } } + private void SetMapTransform(Matrix matrix) + { + if (Data.Transform is MatrixTransform transform && !transform.IsFrozen) + { + transform.Matrix = matrix; + } + else + { + Data.Transform = new MatrixTransform(matrix); + } + } + #region Methods used only by derived classes MapPolyline, MapPolygon and MapMultiPolygon protected void DataCollectionPropertyChanged(DependencyPropertyChangedEventArgs e) diff --git a/MapControl/WinUI/MapPath.WinUI.cs b/MapControl/WinUI/MapPath.WinUI.cs index ede8fbf1..cbd6a6df 100644 --- a/MapControl/WinUI/MapPath.WinUI.cs +++ b/MapControl/WinUI/MapPath.WinUI.cs @@ -25,7 +25,19 @@ namespace MapControl MapPanel.InitMapElement(this); } -#region Methods used only by derived classes MapPolyline and MapPolygon + private void SetMapTransform(Matrix matrix) + { + if (Data.Transform is MatrixTransform transform) + { + transform.Matrix = matrix; + } + else + { + Data.Transform = new MatrixTransform { Matrix = matrix }; + } + } + + #region Methods used only by derived classes MapPolyline and MapPolygon protected void DataCollectionPropertyChanged(DependencyPropertyChangedEventArgs e) {