diff --git a/MapControl/UWP/MapPolygon.UWP.cs b/MapControl/UWP/MapPolygon.UWP.cs index 3c4575c3..a6c0d27a 100644 --- a/MapControl/UWP/MapPolygon.UWP.cs +++ b/MapControl/UWP/MapPolygon.UWP.cs @@ -32,7 +32,7 @@ namespace MapControl var figures = ((PathGeometry)Data).Figures; figures.Clear(); - if (ParentMap != null && Locations != null) + if (ParentMap != null && Locations != null && Locations.Count() >= 2) { var locations = Locations; var offset = GetLongitudeOffset(); @@ -43,12 +43,9 @@ namespace MapControl } var points = locations.Select(loc => ParentMap.MapProjection.LocationToViewportPoint(loc)).ToList(); + points.Add(points[0]); - if (points.Count >= 2) - { - points.Add(points[0]); - CreatePolylineFigures(points); - } + CreatePolylineFigures(points); } } } diff --git a/MapControl/UWP/MapPolyline.UWP.cs b/MapControl/UWP/MapPolyline.UWP.cs index c94bab00..d37afc67 100644 --- a/MapControl/UWP/MapPolyline.UWP.cs +++ b/MapControl/UWP/MapPolyline.UWP.cs @@ -31,7 +31,7 @@ namespace MapControl { ((PathGeometry)Data).Figures.Clear(); - if (ParentMap != null && Locations != null) + if (ParentMap != null && Locations != null && Locations.Count() >= 2) { var locations = Locations; var offset = GetLongitudeOffset(); @@ -43,10 +43,7 @@ namespace MapControl var points = locations.Select(loc => ParentMap.MapProjection.LocationToViewportPoint(loc)).ToList(); - if (points.Count >= 2) - { - CreatePolylineFigures(points); - } + CreatePolylineFigures(points); } } } diff --git a/MapControl/WPF/MapMultiPolygon.WPF.cs b/MapControl/WPF/MapMultiPolygon.WPF.cs index 2bd986db..f75c30d4 100644 --- a/MapControl/WPF/MapMultiPolygon.WPF.cs +++ b/MapControl/WPF/MapMultiPolygon.WPF.cs @@ -38,7 +38,7 @@ namespace MapControl if (ParentMap != null && Polygons != null) { - foreach (var polygon in Polygons.Where(p => p.Any())) + foreach (var polygon in Polygons.Where(p => p.Count() >= 2)) { var points = polygon.Select(loc => LocationToPoint(loc)); var polyline = new PolyLineSegment(points.Skip(1), true); diff --git a/MapControl/WPF/MapPolygon.WPF.cs b/MapControl/WPF/MapPolygon.WPF.cs index 3478a50d..eea01ffb 100644 --- a/MapControl/WPF/MapPolygon.WPF.cs +++ b/MapControl/WPF/MapPolygon.WPF.cs @@ -33,7 +33,7 @@ namespace MapControl { Data.Figures.Clear(); - if (ParentMap != null && Locations != null && Locations.Any()) + if (ParentMap != null && Locations != null && Locations.Count() >= 2) { var points = Locations.Select(loc => LocationToPoint(loc)); var polyline = new PolyLineSegment(points.Skip(1), true); diff --git a/MapControl/WPF/MapPolyline.WPF.cs b/MapControl/WPF/MapPolyline.WPF.cs index 5dae093c..c413d7b8 100644 --- a/MapControl/WPF/MapPolyline.WPF.cs +++ b/MapControl/WPF/MapPolyline.WPF.cs @@ -33,7 +33,7 @@ namespace MapControl { Data.Figures.Clear(); - if (ParentMap != null && Locations != null && Locations.Any()) + if (ParentMap != null && Locations != null && Locations.Count() >= 2) { var points = Locations.Select(loc => LocationToPoint(loc)); var polyline = new PolyLineSegment(points.Skip(1), true);