Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
390
how to draw curve lines using PathElements on xamMap control
posted

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.

 

 

Parents
  • 28496
    Offline posted

    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;

            }

Reply Children