Map Shape Labels in WPF Maps (SfMap)

Labels for map shapes can be displayed by using the LabelPath of ShapeFileLayer. The value of LabelPath must be a field name specified in the .dbf file corresponding to the shapefile.

Property Type Description
LabelPath string Gets or sets the field name in the database (.dbf) file.
  • xaml
  • <syncfusion:SfMap>
                <syncfusion:SfMap.Layers>
                    <syncfusion:ShapeFileLayer x:Name="shapeFileLayer"   
                                           Uri="DataMarkers.ShapeFiles.world1.shp"                                                               
                                           LabelPath="NAME" FontSize="14">
                    </syncfusion:ShapeFileLayer>
                </syncfusion:SfMap.Layers>
            </syncfusion:SfMap>

    The labels can also be customized by modifying the ItemsTemplate of ShapeFileLayer. The labels can be accessed by using DBFData as follows:

  • xaml
  • <syncfusion:SfMap>
                <syncfusion:SfMap.Layers>
                    <syncfusion:ShapeFileLayer Uri="DataMarkers.ShapeFiles.world1.shp"
                                           LabelPath="NAME">
                        <syncfusion:ShapeFileLayer.ItemsTemplate>
                            <DataTemplate>
                                <Grid Background="Gray" Opacity="0.75">
                                    <TextBlock Text="{Binding DBFData[NAME]}"
                                           FontSize="14" Margin="10 5"/>
                                </Grid>
                            </DataTemplate>
                        </syncfusion:ShapeFileLayer.ItemsTemplate>
                    </syncfusion:ShapeFileLayer>
                </syncfusion:SfMap.Layers>
            </syncfusion:SfMap>

    Maps control Shape labels