diff --git a/MapControl/Shared/MapPath.cs b/MapControl/Shared/MapPath.cs index 4ff3a054..997f5c5e 100644 --- a/MapControl/Shared/MapPath.cs +++ b/MapControl/Shared/MapPath.cs @@ -139,35 +139,27 @@ namespace MapControl return longitudeOffset; } - protected PathFigureCollection GetPolylineFigures(IEnumerable locations, bool closed) + protected void AddPolylinePoints(PathFigureCollection pathFigures, IEnumerable locations, bool closed) { - var pathFigures = new PathFigureCollection(); - if (parentMap != null && locations != null) { var longitudeOffset = GetLongitudeOffset(Location ?? locations.FirstOrDefault()); - AddPolylineLocations(pathFigures, locations, longitudeOffset, closed); + AddPolylinePoints(pathFigures, locations, longitudeOffset, closed); } - - return pathFigures; } - protected PathFigureCollection GetMultiPolygonFigures(IEnumerable> polygons) + protected void AddMultiPolygonPoints(PathFigureCollection pathFigures, IEnumerable> polygons) { - var pathFigures = new PathFigureCollection(); - if (parentMap != null && polygons != null) { var longitudeOffset = GetLongitudeOffset(Location); foreach (var polygon in polygons) { - AddPolylineLocations(pathFigures, polygon, longitudeOffset, true); + AddPolylinePoints(pathFigures, polygon, longitudeOffset, true); } } - - return pathFigures; } #endregion diff --git a/MapControl/Shared/MapPolygon.cs b/MapControl/Shared/MapPolygon.cs index 4fea2c1d..e79325d1 100644 --- a/MapControl/Shared/MapPolygon.cs +++ b/MapControl/Shared/MapPolygon.cs @@ -54,7 +54,9 @@ namespace MapControl protected override void UpdateData() { - ((PathGeometry)Data).Figures = GetPolylineFigures(Locations, true); + var figures = ((PathGeometry)Data).Figures; + figures.Clear(); + AddPolylinePoints(figures, Locations, true); } } } diff --git a/MapControl/Shared/MapPolyline.cs b/MapControl/Shared/MapPolyline.cs index 208ba798..09cbbad9 100644 --- a/MapControl/Shared/MapPolyline.cs +++ b/MapControl/Shared/MapPolyline.cs @@ -54,7 +54,9 @@ namespace MapControl protected override void UpdateData() { - ((PathGeometry)Data).Figures = GetPolylineFigures(Locations, false); + var figures = ((PathGeometry)Data).Figures; + figures.Clear(); + AddPolylinePoints(figures, Locations, false); } } } diff --git a/MapControl/WPF/MapMultiPolygon.WPF.cs b/MapControl/WPF/MapMultiPolygon.WPF.cs index fcdd901a..654b5bba 100644 --- a/MapControl/WPF/MapMultiPolygon.WPF.cs +++ b/MapControl/WPF/MapMultiPolygon.WPF.cs @@ -48,7 +48,9 @@ namespace MapControl protected override void UpdateData() { - ((PathGeometry)Data).Figures = GetMultiPolygonFigures(Polygons); + var figures = ((PathGeometry)Data).Figures; + figures.Clear(); + AddMultiPolygonPoints(figures, Polygons); } } } diff --git a/MapControl/WPF/MapPath.WPF.cs b/MapControl/WPF/MapPath.WPF.cs index 0d6019f9..7f40078a 100644 --- a/MapControl/WPF/MapPath.WPF.cs +++ b/MapControl/WPF/MapPath.WPF.cs @@ -86,7 +86,7 @@ namespace MapControl return true; } - protected void AddPolylineLocations(PathFigureCollection pathFigures, IEnumerable locations, double longitudeOffset, bool closed) + protected void AddPolylinePoints(PathFigureCollection pathFigures, IEnumerable locations, double longitudeOffset, bool closed) { if (locations.Count() >= 2) { diff --git a/MapControl/WinUI/MapPath.WinUI.cs b/MapControl/WinUI/MapPath.WinUI.cs index 40e975af..1a5149b0 100644 --- a/MapControl/WinUI/MapPath.WinUI.cs +++ b/MapControl/WinUI/MapPath.WinUI.cs @@ -60,7 +60,7 @@ namespace MapControl UpdateData(); } - protected void AddPolylineLocations(PathFigureCollection pathFigures, IEnumerable locations, double longitudeOffset, bool closed) + protected void AddPolylinePoints(PathFigureCollection pathFigures, IEnumerable locations, double longitudeOffset, bool closed) { if (locations.Count() >= 2) {