You can connect geographic coordinates with a polyline by adding a C1VectorPolyline to the C1VectorLayer (see Vector Layer for more information). In this topic, you will create a 3-point polyline using XAML and code.
In XAML
Complete the following steps:
<c1:C1Maps>
and </c1:C1Maps>
tags:
C# |
Copy Code
|
---|---|
<c1:C1VectorLayer Margin="2,0,-2,0"> <c1:C1VectorPolyline Points="-80.15,42.12 -123.08,39.09, -3.90,30.85" StrokeThickness="3" Stroke="Red"> </c1:C1VectorPolyline> </c1:C1VectorLayer> |
In Code
Complete the following steps:
Visual Basic |
Copy Code
|
---|---|
Imports C1.Silverlight.C1Maps
|
C# |
Copy Code
|
---|---|
using C1.Silverlight.C1Maps;
|
Visual Basic |
Copy Code
|
---|---|
' Create layer and add it to the map Dim C1VectorLayer1 As New C1VectorLayer() C1Maps1.Layers.Add(C1VectorLayer1) ' Initial track Dim pts As Point() = New Point() {New Point(-80.15, 42.12), New Point(-123.08, 39.09), New Point(-3.9, 30.85)} ' Create collection and fill it Dim pcoll As New PointCollection() For Each pt As Point In pts pcoll.Add(pt) Next ' Create a polyline and add it to the vector layer as a child Dim C1VectorPolyline1 As New C1VectorPolyline() C1VectorLayer1.Children.Add(C1VectorPolyline1) ' Points C1VectorPolyline1.Points = pcoll ' Appearance C1VectorPolyline1.Stroke = New SolidColorBrush(Colors.Red) C1VectorPolyline1.StrokeThickness = 3 |
C# |
Copy Code
|
---|---|
// Create layer and add it to the map C1VectorLayer C1VectorLayer1 = new C1VectorLayer(); c1Maps1.Layers.Add(C1VectorLayer1); // Initial track Point[] pts = new Point[] { new Point(-80.15,42.12), new Point(-123.08,39.09), new Point(-3.90,30.85)}; // Create collection and fill it PointCollection pcoll = new PointCollection(); foreach( Point pt in pts) pcoll.Add(pt); // Create a polyline and add it to the vector layer as a child C1VectorPolyline C1VectorPolyline1 = new C1VectorPolyline(); v1.Children.Add(C1VectorPolyline1); // Points C1VectorPolyline1.Points = pcoll; // Appearance C1VectorPolyline1.Stroke = new SolidColorBrush(Colors.Red); C1VectorPolyline1.StrokeThickness = 3; |
This Topic Illustrates the Following:
The following image depicts a C1Maps control with three geographical coordinates connected by a polyline.