Version

Add Symbol Element

If you need to add a marker for points of interests in xamMap™, you can use the SymbolElement object. This derived MapElement type allows you to add predefined shapes to the control. You can use Cartesian or Geodetic coordinates to define the placement of the symbol.

The following code shows you how to add a diamond-shaped Symbol Element at the Equator using Geodetic coordinates.

In XAML:

<igMap:XamMap x:Name="xamMap">
   <igMap:XamMap.Layers>
      <igMap:MapLayer x:Name="worldLayer" Imported="worldLayer_Imported">
         <igMap:MapLayer.Reader>
            <igMap:ShapeFileReader Uri="/../../Shapefiles/world" DataMapping="Name=CNTRY_NAME; Caption=CNTRY_NAME" />
         </igMap:MapLayer.Reader>
      </igMap:MapLayer>
   </igMap:XamMap.Layers>
</igMap:XamMap>

In Visual Basic:

Private Sub worldLayer_Imported(ByVal sender As System.Object, ByVal e As Infragistics.Controls.Maps.MapLayerImportEventArgs)
        If e.Action = MapLayerImportAction.End Then
            ' Coordinates for point at equator
            Dim latitude As Double = 0
            Dim longitude As Double = 0
            ' Get Point data using a projection from Geodetic to Cartesian coordinates
            Dim origin As Point = xamMap.MapProjection.ProjectToMap(New Point(longitude, latitude))
            Dim element As New SymbolElement()
            element.SymbolOrigin = origin
            element.Caption = "Marker"
            element.SymbolType = MapSymbolType.Diamond
            element.SymbolSize = 10
            xamMap.Layers(0).Elements.Add(element)
        End If
End Sub

In C#:

private void worldLayer_Imported(object sender, MapLayerImportEventArgs e)
{
   if (e.Action == MapLayerImportAction.End)
   {
       // Coordinates for point at equator
       double latitude = 0;
       double longitude = 0;
       // Get Point data using a projection from Geodetic to Cartesian coordinates
       Point origin = xamMap.MapProjection.ProjectToMap(new Point(longitude, latitude));
       SymbolElement element = new SymbolElement()
       { SymbolOrigin = origin, Caption = "Marker", SymbolType = MapSymbolType.Diamond, SymbolSize = 10 };
       xamMap.Layers[0].Elements.Add(element);
    }
 }
xamMap Add Symbol Element 01.png