Requirement:
Need to draw multiple lines from a location to any distination. There can be multiple line going out from a location to the same destination. So using PathElements we need to draw multiline for this.
Kindly suggest us a solution or with an example for this requirement for us.
here is some code to add a path to a map using C#:
<ig:XamMap Name="xamMap1">
<ig:XamMap.Layers>
<ig:MapLayer Name="world">
<ig:MapLayer.Reader>
<ig:ShapeFileReader Uri="world" />
</ig:MapLayer.Reader>
</ig:MapLayer>
<ig:MapLayer Name="paths" />
</ig:XamMap.Layers>
<Button Height="25" Width="50" Content="click me" Click="Button_Click" />
</ig:XamMap>
private void Button_Click(object sender, RoutedEventArgs e)
{
Point denver = new Point(-105, 39);
denver = this.xamMap1.MapProjection.ProjectToMap(denver);
Point dallas = new Point(-96, 32);
dallas = this.xamMap1.MapProjection.ProjectToMap(dallas);
Point worldRectTopLeft = new Point(Math.Min(denver.X, dallas.X), Math.Min(denver.Y, dallas.Y));
Point worldRectBottomRight = new Point(Math.Max(denver.X, dallas.X), Math.Max(denver.Y, dallas.Y));
Rect worldRect = new Rect(worldRectTopLeft, worldRectBottomRight);
PathElement el = new PathElement();
MapPolyline oly = new MapPolyline();
oly.Add(denver);
oly.Add(dallas);
el.Polylines = new MapPolylineCollection();
el.Polylines.Add(oly);
el.StrokeThickness = 5.0;
el.Fill = new SolidColorBrush(Colors.Red);
this.xamMap1.Layers["paths"].Elements.Add(el);
this.xamMap1.Layers["paths"].WorldRect = worldRect;
}
I want to draw curved multiline. How to draw curved line?
Hi
You can use something like this:
var p0 = new Point(100, 300);var p1 = new Point(200, 250);var p2 = new Point(500, 300);
var a = (p0.X * (p1.Y - p2.Y) + p0.Y * (p2.X - p1.X) + p1.X * p2.Y - p2.X * p1.Y) / ((p1.X - p0.X) * (p2.X - p0.X) * (p2.X - p1.X));var b = (p2.Y - p0.Y) / (p2.X - p0.X) - (p2.X + p0.X) * a;var c = p0.Y - a * p0.X * p0.X - b * p0.X;var poly = new Polyline();for (double x = p0.X; x < p2.X; x++){ var y = a * x * x + b * x + c; poly.Points.Add(new Point(x, y));}
which will produce the following curve:
You can apply this to David's solution where p0 is "denver", p2 is "dallas" and p1 is a suitable point between p0 and p2.
Also you can submitting a feature request for curve lines here: https://es.infragistics.com/community/ideas