New to Telerik UI for .NET MAUI? Start a free 30-day trial

.NET MAUI Map Label Styling

The Map ShapefileLayer has a ShapeLabelStyle property that is of MapShapeLabelStyle type and defines the style of the labels.

MapShapeLabelStyle provides the following properties you could use to customize the way labels on the map will look:

  • TextColor
  • FontSize
  • FontFamily
  • FontAttributes

The example shows the ShapeLabelStyle property applied:

<telerik:RadMap x:Name="map">
    <telerik:RadMap.Layers>
        <telerik:ShapefileLayer LabelAttributeName="CNTRY_NAME">
            <telerik:ShapefileLayer.Reader>
                <telerik:MapShapeReader x:Name="reader"/>
            </telerik:ShapefileLayer.Reader>
            <telerik:ShapefileLayer.ShapeLabelStyle>
                <telerik:MapShapeLabelStyle TextColor="DarkRed"
                                               FontAttributes="Bold"
                                               FontSize="12"
                                               FontFamily="Arial"/>
            </telerik:ShapefileLayer.ShapeLabelStyle>
        </telerik:ShapefileLayer>
    </telerik:RadMap.Layers>
</telerik:RadMap>

where the Source and the DataSource of the MapShapeReader should be set to a .shp and .dbf files, respectively:

var assembly = this.GetType().Assembly;
var source = MapSource.FromResource("SDKBrowserMaui.Examples.MapControl.world.shp", assembly);
this.reader.Source = source;

And the used namespace:

xmlns:telerikMap="clr-namespace:Telerik.XamarinForms.Map;assembly=Telerik.Maui.Controls.Compatibility"

Here is the result:

Map Labels Styling

See Also

In this article
Not finding the help you need?