ComponentOne Maps for UWP
C1MapsFeatures / Vector Layer / Vector Objects
In This Topic
    Vector Objects
    In This Topic

    There are following main vector elements that can be used on the vector layer:

    Sometimes, you may need to mark a route, like a travel route, on your map. Using the C1VectorPolyline class, you can do this easily either in XAML markup or in code:

    In XAML

    Place the following XAML markup between the <c1:C1Maps> and </c1:C1Maps> tags:

    XAML
    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:

    1. In XAML view, add x:Name="C1Maps1" to the <c1:C1Maps> tag so that the object will have a unique identifier for you to call in code.
    1. Add the following code beneath the InitializeComponent() method:
    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();
    C1VectorLayer1.Children.Add(C1VectorPolyline1);
    // Points
    C1VectorPolyline1.Points = pcoll;
    // Appearance
    C1VectorPolyline1.Stroke = new SolidColorBrush(Colors.Red);
    C1VectorPolyline1.StrokeThickness = 3;
    
    1. Press F5 to run the project.

    This Topic Illustrates the Following:

    The following image depicts a C1Maps control with three geographical coordinates connected by a polyline.

                   

     

    You might want to mark a border or region on your C1Maps control. With the C1VectorPolygons class, it's easy to accomplish this either using XAML markup or code:

    In XAML

    Place the following XAML markup between the <c1:C1Maps> and </c1:C1Maps> tags:         

    XAML
    Copy Code
    <C1:C1VectorLayer Margin="2,0,-2,0">
         <C1:C1VectorPolygon Points="-80.15,42.12 -123.08,39.09, -3.90,30.85" StrokeThickness="3" Stroke="Red">
         </C1:C1VectorPolygon>
    </C1:C1VectorLayer>
    

     

    In Code

    Complete the following steps:

    1. In XAML view, add x:Name="C1Maps1" to the <c1:C1Maps> tag so that the object will have a unique identifier for you to call in code.
    1. Add the following code beneath the InitializeComponent() method:
    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 polygon and add it to the vector layer as a child
    Dim C1VectorPolygon1 As New C1VectorPolygon()
    C1VectorLayer1.Children.Add(C1VectorPolygon1)
    ' Points
    C1VectorPolygon1.Points = pcoll
    ' Appearance
    C1VectorPolygon1.Stroke = New SolidColorBrush(Colors.Red)
    C1VectorPolygon1.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 polygon and add it to the vector layer as a child
    C1VectorPolygon C1VectorPolygon1 = new C1VectorPolygon();
    C1VectorLayer1.Children.Add(C1VectorPolygon1);
    // Points
    C1VectorPolygon1.Points = pcoll;
    // Appearance
    C1VectorPolygon1.Stroke = new SolidColorBrush(Colors.Red);
    C1VectorPolygon1.StrokeThickness = 3;
    
    1. Press F5 to run the project.

    This Topic Illustrates the Following:

    The following image depicts a C1Maps control with three geographical coordinates connected by a polygon. 

     

    C1VectorPlacemark is attached to a geographical point. Placemarks have scale-independent geometry in which coordinates are expressed in pixel coordinates and an optional label. Typically, a placemark is used as a label, icon, or mark on the map control. You can add a placemark using either XAML markup or code:

    In XAML

    Add the following XAML between the <c1:C1Maps> and </c1:C1Maps> tags:

    XAML
    Copy Code
    <C1:C1VectorLayer>
    <C1:C1VectorPlacemark LabelPosition="Left" GeoPoint="-80.107008,42.16389" StrokeThickness="2" Foreground="#FFEB1212" PinPoint="-80.010866,42.156831" Label="Erie, PA"/>
    </C1:C1VectorLayer>
    

     

    In Code

    1. In XAML view, add x:Name="C1Maps1" to the <c1:C1Maps> tag so that the object will have a unique identifier for you to call in code.
    1. Add the following code beneath the InitializeComponent() method:
    Visual Basic
    Copy Code
    ' Create layer and add it to the map
    Dim vl As C1VectorLayer = New C1VectorLayer()
    C1Maps1.Layers.Add(vl)
    'Create a vector placemark and add it to the layer
    Dim vp1 As C1VectorPlacemark = New C1VectorPlacemark()
    vl.Children.Add(vp1)
    ' Set the placemark to a set of geographical coordinates
    vp1.GeoPoint = New Point(-80.107008, 42.16389)
     
    ' Set the placemark's label and properties
    vp1.Label = "Erie, PA"
    vp1.FontSize = 12
    vp1.Foreground = New SolidColorBrush(Colors.Red)
    vp1.LabelPosition = LabelPosition.Center
    

    C#
    Copy Code
    // Create layer and add it to the map
    C1VectorLayer vl = new C1VectorLayer();
    C1Maps1.Layers.Add(vl);
    //Create a vector placemark and add it to the layer
    C1VectorPlacemark vp1 = new C1VectorPlacemark();
    vl.Children.Add(vp1);
    // Set the placemark to a set of geographical coordinates
    vp1.GeoPoint = new Point(-80.107008, 42.16389);
    // Set the placemark's label and properties
    vp1.Label = "Erie, PA";
    vp1.FontSize = 12;
    vp1.Foreground = new SolidColorBrush(Colors.Red);
    vp1.LabelPosition = LabelPosition.Center;
    
    1. Run the project.

     This Topic Illustrates the Following:

    The following image shows a C1Maps control with the geographic coordinates of Erie, Pennsylvania (USA) labeled.