diff --git a/MapControl/Shared/MapPanel.cs b/MapControl/Shared/MapPanel.cs index 1bf04eda..1749b315 100644 --- a/MapControl/Shared/MapPanel.cs +++ b/MapControl/Shared/MapPanel.cs @@ -187,7 +187,7 @@ namespace MapControl return finalSize; } - protected Point? GetViewPosition(Location location) + private Point? GetViewPosition(Location location) { var position = parentMap.LocationToView(location); @@ -206,7 +206,7 @@ namespace MapControl return position; } - protected Rect? GetViewRect(BoundingBox boundingBox) + private Rect? GetViewRect(BoundingBox boundingBox) { var mapRect = parentMap.MapProjection.BoundingBoxToMap(boundingBox); @@ -218,16 +218,15 @@ namespace MapControl return null; } - protected Rect GetViewRect(Rect mapRect) + private Rect GetViewRect(Rect mapRect) { var center = new Point(mapRect.X + mapRect.Width / 2d, mapRect.Y + mapRect.Height / 2d); var position = parentMap.ViewTransform.MapToView(center); - var projection = parentMap.MapProjection; - if (projection.Type <= MapProjectionType.NormalCylindrical && + if (parentMap.MapProjection.Type <= MapProjectionType.NormalCylindrical && !parentMap.InsideViewBounds(position)) { - var location = projection.MapToLocation(center); + var location = parentMap.MapProjection.MapToLocation(center); if (location != null) { diff --git a/MapControl/Shared/WmsImageLayer.cs b/MapControl/Shared/WmsImageLayer.cs index c170aa42..69465079 100644 --- a/MapControl/Shared/WmsImageLayer.cs +++ b/MapControl/Shared/WmsImageLayer.cs @@ -236,7 +236,8 @@ namespace MapControl return null; } - var viewScale = ParentMap.ViewTransform.Scale; + var width = ParentMap.ViewTransform.Scale * mapRect.Value.Width; + var height = ParentMap.ViewTransform.Scale * mapRect.Value.Height; return GetRequestUri(new Dictionary { @@ -248,8 +249,8 @@ namespace MapControl { "FORMAT", "image/png" }, { "CRS", GetCrsValue() }, { "BBOX", GetBboxValue(mapRect.Value) }, - { "WIDTH", Math.Round(viewScale * mapRect.Value.Width).ToString("F0") }, - { "HEIGHT", Math.Round(viewScale * mapRect.Value.Height).ToString("F0") } + { "WIDTH", Math.Round(width).ToString("F0") }, + { "HEIGHT", Math.Round(height).ToString("F0") } }); } @@ -267,12 +268,13 @@ namespace MapControl return null; } - var viewRect = GetViewRect(mapRect.Value); + var width = ParentMap.ViewTransform.Scale * mapRect.Value.Width; + var height = ParentMap.ViewTransform.Scale * mapRect.Value.Height; var transform = ViewTransform.CreateTransformMatrix( -viewport.Width / 2d, -viewport.Height / 2d, -ParentMap.ViewTransform.Rotation, - viewRect.Width / 2d, viewRect.Height / 2d); + width / 2d, height / 2d); var imagePos = transform.Transform(position); @@ -287,8 +289,8 @@ namespace MapControl { "INFO_FORMAT", format }, { "CRS", GetCrsValue() }, { "BBOX", GetBboxValue(mapRect.Value) }, - { "WIDTH", Math.Round(viewRect.Width).ToString("F0") }, - { "HEIGHT", Math.Round(viewRect.Height).ToString("F0") }, + { "WIDTH", Math.Round(width).ToString("F0") }, + { "HEIGHT", Math.Round(height).ToString("F0") }, { "I", Math.Round(imagePos.X).ToString("F0") }, { "J", Math.Round(imagePos.Y).ToString("F0") } };