Rotatable shape

Within this forum we want to offer discussions all around our .NET based Map control including all .Net-language specific questions concerning calls of the xServer-API. Attention: xServer-relevant concepts can be found in further forums such as xRoute or xTour.
Post Reply
Joost
Posts: 307
Joined: Fri Apr 25, 2014 1:46 pm

Rotatable shape

Post by Joost »

I'm looking for a way to rotate shapes drawn onto the map so that I can align measured GPS potions with their heading. I have tried using the TriangleUp class and added a RotateTransform as it's RenderTransform but I can't get the shape to rotate. Any Idea how i can rotate the shapes?
Joost Claessen
Senior Technical Consultant
PTV Benelux
User avatar
Oliver Heilig
Posts: 154
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany
Contact:

Re: Rotatable shape

Post by Oliver Heilig »

Hello Joost,

you can rotate any WPF element for the map using the RenderTransform property. One caveat: You cannot directly set the RenderTransform of the element. Because the RenderTransform set by the map control, you need to put it in a container first. Here's a sample to rotate the ballons for https://github.com/ptv-logistics/xserve ... ultiCanvas

Oli

Code: Select all

public void AddBalloon(MultiCanvasShapeLayer layer, double lat, double lon, Color color, string text, string tooltip)
{
    // create and initialize balloon
    var balloon = new Balloon
    {
        Color = color,
        Text = text,
        ToolTip = tooltip,
        RenderTransform = new RotateTransform(45), // rotation
        RenderTransformOrigin = new System.Windows.Point(0.5, 0.5) // rotation center
    };

    var balloonContainer = new Grid();
    balloonContainer.Children.Add(balloon);

    // set geo location
    ShapeCanvas.SetLocation(balloonContainer, new System.Windows.Point(lon, lat));

    // optional use adaptive (zoom-dependent scaling)
    ShapeCanvas.SetScale(balloonContainer, 2.5);
    ShapeCanvas.SetScaleFactor(balloonContainer, 0.1);

    // add to map
    layer.TopShapes.Add(balloonContainer);
}
Attachments
RotatedIcons.png
Oliver Heilig
Chief Developer Logistic Services
PTV GROUP - Germany

https://github.com/oliverheilig/
Joost
Posts: 307
Joined: Fri Apr 25, 2014 1:46 pm

Re: Rotatable shape

Post by Joost »

Works like a charm. Thnx for the info.
Joost Claessen
Senior Technical Consultant
PTV Benelux
Post Reply