mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-02-28 18:46:48 +01:00
Size validation in MapImageLayer
This commit is contained in:
parent
3d386e01db
commit
db3cf3ea81
|
|
@ -2,8 +2,6 @@
|
||||||
#if WPF
|
#if WPF
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
#elif UWP
|
#elif UWP
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
|
|
|
||||||
|
|
@ -183,20 +183,22 @@ namespace MapControl
|
||||||
BoundingBox boundingBox = null;
|
BoundingBox boundingBox = null;
|
||||||
|
|
||||||
if (ParentMap != null &&
|
if (ParentMap != null &&
|
||||||
ParentMap.ActualWidth > 0d &&
|
|
||||||
ParentMap.ActualHeight > 0d &&
|
|
||||||
(SupportedCrsIds == null || SupportedCrsIds.Contains(ParentMap.MapProjection.CrsId)))
|
(SupportedCrsIds == null || SupportedCrsIds.Contains(ParentMap.MapProjection.CrsId)))
|
||||||
{
|
{
|
||||||
var width = ParentMap.ActualWidth * RelativeImageSize;
|
var width = ParentMap.ActualWidth * RelativeImageSize;
|
||||||
var height = ParentMap.ActualHeight * 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