mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-02-27 01:54:22 +01:00
Size validation in MapImageLayer
This commit is contained in:
parent
3d386e01db
commit
db3cf3ea81
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue