Update MapPanel.cs

This commit is contained in:
ClemensF 2021-01-15 18:00:51 +01:00
parent bcc033e5cd
commit 2208f6c3da

View file

@ -116,7 +116,7 @@ namespace MapControl
var position = parentMap.LocationToView(location);
if (parentMap.MapProjection.IsNormalCylindrical && !IsInsideViewport(position))
if (parentMap.MapProjection.IsNormalCylindrical && IsOutsideViewport(position))
{
location = new Location(location.Latitude, parentMap.ConstrainedLongitude(location.Longitude));
@ -142,7 +142,7 @@ namespace MapControl
var center = new Point(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d);
var position = parentMap.ViewTransform.MapToView(center);
if (parentMap.MapProjection.IsNormalCylindrical && !IsInsideViewport(position))
if (parentMap.MapProjection.IsNormalCylindrical && IsOutsideViewport(position))
{
var location = parentMap.MapProjection.MapToLocation(center);
location.Longitude = parentMap.ConstrainedLongitude(location.Longitude);
@ -209,7 +209,7 @@ namespace MapControl
if (GetAutoCollapse(element))
{
if (position.HasValue && !IsInsideViewport(position.Value))
if (position.HasValue && IsOutsideViewport(position.Value))
{
element.SetValue(VisibilityProperty, Visibility.Collapsed);
}
@ -242,10 +242,10 @@ namespace MapControl
return finalSize;
}
private bool IsInsideViewport(Point point)
private bool IsOutsideViewport(Point point)
{
return point.X >= 0d && point.X <= parentMap.RenderSize.Width
&& point.Y >= 0d && point.Y <= parentMap.RenderSize.Height;
return point.X < 0d || point.X > parentMap.RenderSize.Width
|| point.Y < 0d || point.Y > parentMap.RenderSize.Height;
}
private static void ArrangeElement(FrameworkElement element, ViewRect rect)