From 5d8f1b5ff0964c2a1594b78cc483e8b552611ebc Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Tue, 30 Dec 2025 00:26:08 +0100 Subject: [PATCH] Updated MapProjection --- MapControl/Shared/MapImageLayer.cs | 6 +++++- MapControl/Shared/MapPanel.cs | 6 +++--- MapControl/Shared/MapProjection.cs | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/MapControl/Shared/MapImageLayer.cs b/MapControl/Shared/MapImageLayer.cs index 43c7a345..470aa7ed 100644 --- a/MapControl/Shared/MapImageLayer.cs +++ b/MapControl/Shared/MapImageLayer.cs @@ -193,7 +193,11 @@ namespace MapControl var y = (ParentMap.ActualHeight - height) / 2d; boundingBox = ParentMap.ViewRectToBoundingBox(x, y, width, height); - image = await GetImageAsync(boundingBox, loadingProgress); + + if (boundingBox != null) + { + image = await GetImageAsync(boundingBox, loadingProgress); + } } SwapImages(image, boundingBox); diff --git a/MapControl/Shared/MapPanel.cs b/MapControl/Shared/MapPanel.cs index b97331eb..980e5c6b 100644 --- a/MapControl/Shared/MapPanel.cs +++ b/MapControl/Shared/MapPanel.cs @@ -293,10 +293,10 @@ namespace MapControl { var rotatedRect = parentMap.MapProjection.LatLonBoxToMap(latLonBox); - if (rotatedRect != null) + if (rotatedRect.HasValue) { - mapRect = rotatedRect.Item1; - rotation = -rotatedRect.Item2; + mapRect = rotatedRect.Value.Item1; + rotation = -rotatedRect.Value.Item2; } } else diff --git a/MapControl/Shared/MapProjection.cs b/MapControl/Shared/MapProjection.cs index 8a2aaea9..8c0d62f5 100644 --- a/MapControl/Shared/MapProjection.cs +++ b/MapControl/Shared/MapProjection.cs @@ -114,9 +114,9 @@ namespace MapControl /// Transforms a LatLonBox in geographic coordinates to a rotated Rect in projected map coordinates. /// Returns null when the LatLonBox can not be transformed. /// - public virtual Tuple LatLonBoxToMap(LatLonBox latLonBox) + public virtual (Rect, double)? LatLonBoxToMap(LatLonBox latLonBox) { - Tuple rotatedRect = null; + (Rect, double)? rotatedRect = null; Point? center, north, south, west, east; var centerLatitude = latLonBox.Center.Latitude; var centerLongitude = latLonBox.Center.Longitude; @@ -142,7 +142,7 @@ namespace MapControl var r1 = (Math.Atan2(dy1, dx1) * 180d / Math.PI + 180d) % 360d - 180d; var r2 = (Math.Atan2(-dx2, dy2) * 180d / Math.PI + 180d) % 360d - 180d; - rotatedRect = new Tuple(new Rect(x, y, width, height), latLonBox.Rotation + (r1 + r2) / 2d); + rotatedRect = (new Rect(x, y, width, height), latLonBox.Rotation + (r1 + r2) / 2d); } return rotatedRect;