Drawing a line with direction indication

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
KasperD
Posts: 14
Joined: Tue Jun 17, 2014 8:15 am

Drawing a line with direction indication

Post by KasperD »

Dear colleagues,

One of our customers is using the RoutePolyLine animation to show users which way the route is going. As this takes up a huge amount of CPU time (25% of 1 core in a quad-core system), he wishes to disable the animation but still show which way the route is going. using the following code:

var poly = new MapPolyline
{
Points = pc,
MapStrokeThickness = 10,
StrokeLineJoin = PenLineJoin.Round,
StrokeStartLineCap = PenLineCap.Flat,
StrokeEndLineCap = PenLineCap.Triangle,
Stroke = new SolidColorBrush(System.Windows.Media.Color.FromArgb(128, color.R, color.G, color.B)),
ScaleFactor = 0.05,
ToolTip = toolTip
};
var polyArrow = new MapPolyline
{
Points = pc,
MapStrokeThickness = 11,
StrokeLineJoin = PenLineJoin.Round,
StrokeStartLineCap = PenLineCap.Flat,
StrokeEndLineCap = PenLineCap.Triangle,
Stroke = new SolidColorBrush(System.Windows.Media.Color.FromArgb(128, color.R, color.G, color.B)),
StrokeDashCap = PenLineCap.Triangle,
StrokeDashArray = new DoubleCollection { 1, 2 },
// StrokeDashOffset = 2.0,
ScaleFactor = 0.05,
ToolTip = toolTip
};

The customer is able to produce a line as shown in the attachment arrow1. however, he would like to have a line as depicted in attachment arrow2. is this possible, code-wise?
Attachments
arrow2.png
arrow2.png (27.29 KiB) Viewed 6686 times
arrow1.png
arrow1.png (17.46 KiB) Viewed 6686 times
Marco

Re: Drawing a line with direction indication

Post by Marco »

Dear Kasper,

out of the box, there is no way to customize the dashes along the routing polyline. In WPF, there exists only four different constants for PenLineCap (flat, round, triangle, square). All of them are symmetric, i.e. it's not possible to show a direction.

To resolve that problem, the customer has to draw the lines manually himself. See here: http://stackoverflow.com/questions/5188 ... e-in-c-wpf

I'm very sorry, but this problem is more complicated and goes beyond our intention of the code samples: We want to show how to use the PTV xServer for implementing desktop applications and avoided complex GUI elements generally.
KasperD
Posts: 14
Joined: Tue Jun 17, 2014 8:15 am

Re: Drawing a line with direction indication

Post by KasperD »

Marco,

Thanks, no problem. Forwarded the information to the customer and he'll find a way to make what he needs.
Post Reply