Update MapPanel.cs

This commit is contained in:
ClemensF 2021-01-15 17:49:59 +01:00
parent e1cd5a64b7
commit bcc033e5cd

View file

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