Page 1 of 1
Rotatable shape
Posted: Mon Nov 26, 2018 3:22 pm
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?
Re: Rotatable shape
Posted: Mon Nov 26, 2018 7:23 pm
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);
}
Re: Rotatable shape
Posted: Mon Dec 03, 2018 9:34 am
by Joost
Works like a charm. Thnx for the info.