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.

Rotatable shape

Postby Joost » Mon Nov 26, 2018 3:22 pm

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
Joost
 
Posts: 237
Joined: Fri Apr 25, 2014 1:46 pm

Re: Rotatable shape

Postby Oliver Heilig » Mon Nov 26, 2018 7:23 pm

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

csharp code
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/
User avatar
Oliver Heilig
 
Posts: 123
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany

Re: Rotatable shape

Postby Joost » Mon Dec 03, 2018 9:34 am

Works like a charm. Thnx for the info.
Joost Claessen
Senior Technical Consultant
PTV Benelux
Joost
 
Posts: 237
Joined: Fri Apr 25, 2014 1:46 pm


Return to PTV xServer.NET (Admin=OH)

cron