mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-09 00:14:51 +00:00
LatLonBoxToMap with rotated skew matrix
This commit is contained in:
parent
ffd1c1c6cd
commit
dbc4c142f7
2 changed files with 22 additions and 14 deletions
|
|
@ -287,15 +287,16 @@ namespace MapControl
|
|||
private void ArrangeElement(FrameworkElement element, BoundingBox boundingBox)
|
||||
{
|
||||
Rect? mapRect;
|
||||
var rotation = 0d;
|
||||
Matrix transform;
|
||||
|
||||
if (boundingBox is LatLonBox latLonBox)
|
||||
{
|
||||
(mapRect, rotation) = parentMap.MapProjection.LatLonBoxToMap(latLonBox);
|
||||
(mapRect, transform) = parentMap.MapProjection.LatLonBoxToMap(latLonBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
mapRect = parentMap.MapProjection.BoundingBoxToMap(boundingBox);
|
||||
transform = new Matrix(1d, 0d, 0d, 1d, 0d, 0d);
|
||||
}
|
||||
|
||||
if (mapRect.HasValue)
|
||||
|
|
@ -306,17 +307,19 @@ namespace MapControl
|
|||
element.Height = viewRect.Height;
|
||||
element.Arrange(viewRect);
|
||||
|
||||
// LatLonBoxToMap rotation is counterclockwise, RotateTransform is clockwise.
|
||||
//
|
||||
rotation = (parentMap.ViewTransform.Rotation - rotation) % 360d;
|
||||
transform.Rotate(parentMap.ViewTransform.Rotation);
|
||||
|
||||
if (element.RenderTransform is RotateTransform rotateTransform)
|
||||
if (element.RenderTransform is MatrixTransform matrixTransform
|
||||
#if WPF
|
||||
&& !matrixTransform.IsFrozen
|
||||
#endif
|
||||
)
|
||||
{
|
||||
rotateTransform.Angle = rotation;
|
||||
matrixTransform.Matrix = transform;
|
||||
}
|
||||
else if (rotation != 0d)
|
||||
else
|
||||
{
|
||||
element.SetRenderTransform(new RotateTransform { Angle = rotation }, true);
|
||||
element.SetRenderTransform(new MatrixTransform { Matrix = transform }, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue