Size validation in MapImageLayer

This commit is contained in:
ClemensFischer 2026-01-08 10:08:55 +01:00
parent 3d386e01db
commit db3cf3ea81
2 changed files with 10 additions and 10 deletions

View file

@ -2,8 +2,6 @@
#if WPF
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
#elif UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;

View file

@ -183,20 +183,22 @@ namespace MapControl
BoundingBox boundingBox = null;
if (ParentMap != null &&
ParentMap.ActualWidth > 0d &&
ParentMap.ActualHeight > 0d &&
(SupportedCrsIds == null || SupportedCrsIds.Contains(ParentMap.MapProjection.CrsId)))
{
var width = ParentMap.ActualWidth * RelativeImageSize;
var height = ParentMap.ActualHeight * RelativeImageSize;
var x = (ParentMap.ActualWidth - width) / 2d;
var y = (ParentMap.ActualHeight - height) / 2d;
var mapRect = ParentMap.ViewTransform.ViewToMapBounds(new Rect(x, y, width, height));
boundingBox = ParentMap.MapProjection.MapToBoundingBox(mapRect);
if (boundingBox != null)
if (width > 0d && height > 0d)
{
image = await GetImageAsync(mapRect, loadingProgress);
var x = (ParentMap.ActualWidth - width) / 2d;
var y = (ParentMap.ActualHeight - height) / 2d;
var mapRect = ParentMap.ViewTransform.ViewToMapBounds(new Rect(x, y, width, height));
boundingBox = ParentMap.MapProjection.MapToBoundingBox(mapRect);
if (boundingBox != null)
{
image = await GetImageAsync(mapRect, loadingProgress);
}
}
}