diff --git a/MapControl/Shared/MapPanel.cs b/MapControl/Shared/MapPanel.cs index 6ed791d1..b9387c1f 100644 --- a/MapControl/Shared/MapPanel.cs +++ b/MapControl/Shared/MapPanel.cs @@ -306,7 +306,9 @@ namespace MapControl element.Height = viewRect.Height; element.Arrange(viewRect); - rotation += parentMap.ViewTransform.Rotation; + // LatLonBoxToMap rotation is counterclockwise, RotateTransform is clockwise. + // + rotation = (parentMap.ViewTransform.Rotation - rotation) % 360d; if (element.RenderTransform is RotateTransform rotateTransform) { diff --git a/MapControl/Shared/MapProjection.cs b/MapControl/Shared/MapProjection.cs index 6fac8b40..d21a6abd 100644 --- a/MapControl/Shared/MapProjection.cs +++ b/MapControl/Shared/MapProjection.cs @@ -193,11 +193,11 @@ namespace MapControl // Additional rotation caused by the projection, calculated as mean value // of the two angles measured relative to the east and north axis. // - var r1 = (Math.Atan2(dy1, dx1) * 180d / Math.PI + 180d) % 360d - 180d; - var r2 = (Math.Atan2(-dx2, dy2) * 180d / Math.PI + 180d) % 360d - 180d; + var r1 = Math.Atan2(dy1, dx1) * 180d / Math.PI; + var r2 = Math.Atan2(-dx2, dy2) * 180d / Math.PI; rect = new Rect(x, y, width, height); - rotation = latLonBox.Rotation + (r1 + r2) / 2d; + rotation = latLonBox.Rotation + (r1 + r2) / 2d % 360d; } return (rect, rotation);