From 75d8d4a70bc6b4db5b086743183a330ee3a0f6d1 Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Fri, 4 Apr 2025 14:35:18 +0200 Subject: [PATCH] Update MapImageLayer.cs --- MapControl/Shared/MapImageLayer.cs | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/MapControl/Shared/MapImageLayer.cs b/MapControl/Shared/MapImageLayer.cs index e9137df7..b1038113 100644 --- a/MapControl/Shared/MapImageLayer.cs +++ b/MapControl/Shared/MapImageLayer.cs @@ -176,10 +176,17 @@ namespace MapControl updateTimer.Stop(); ImageSource image = null; - var boundingBox = GetImageBoundingBox(); + BoundingBox boundingBox = null; - if (boundingBox != null) + if (ParentMap != null && ParentMap.ActualWidth > 0d && ParentMap.ActualHeight > 0d) { + var width = ParentMap.ActualWidth * RelativeImageSize; + var height = ParentMap.ActualHeight * RelativeImageSize; + var x = (ParentMap.ActualWidth - width) / 2d; + var y = (ParentMap.ActualHeight - height) / 2d; + + boundingBox = ParentMap.ViewRectToBoundingBox(new Rect(x, y, width, height)); + image = await GetImageAsync(boundingBox, loadingProgress); } @@ -189,23 +196,6 @@ namespace MapControl } } - private BoundingBox GetImageBoundingBox() - { - BoundingBox boundingBox = null; - - if (ParentMap != null && ParentMap.ActualWidth > 0d && ParentMap.ActualHeight > 0d) - { - var width = ParentMap.ActualWidth * RelativeImageSize; - var height = ParentMap.ActualHeight * RelativeImageSize; - var x = (ParentMap.ActualWidth - width) / 2d; - var y = (ParentMap.ActualHeight - height) / 2d; - - boundingBox = ParentMap.ViewRectToBoundingBox(new Rect(x, y, width, height)); - } - - return boundingBox; - } - private void ClearImages() { foreach (var image in Children.OfType())