menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class MapDataLabelSettings - MAUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class MapDataLabelSettings

    Represents the map data labels settings.

    Inheritance
    System.Object
    MapDataLabelSettings
    Namespace: Syncfusion.Maui.Maps
    Assembly: Syncfusion.Maui.Maps.dll
    Syntax
    public class MapDataLabelSettings : Element, IThemeElement
    Examples
    • XAML
    • C#
    <map:SfMaps>
       <map:SfMaps.BindingContext>
           <local:RangeViewModel/>
       </map:SfMaps.BindingContext>
       <map:SfMaps.Layer>
          <map:MapShapeLayer x:Name="layer"
                             ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json"
                             DataSource="{Binding WorldPopulationDensity}"
                             ShapeDataField="name"
                             PrimaryValuePath="CountryName"
                             ShowDataLabels="True">
    
             <map:MapShapeLayer.DataLabelSettings>
                 <map:MapDataLabelSettings DataLabelPath="Density"
                                           OverflowMode="Trim">
    
                    <map:MapDataLabelSettings.DataLabelStyle>
                        <map:MapLabelStyle TextColor="Green" 
                                           FontSize="12" 
                                           FontAttributes="Bold" />
                    </map:MapDataLabelSettings.DataLabelStyle>
    
                 </map:MapDataLabelSettings>
             </map:MapShapeLayer.DataLabelSettings>
    
          </map:MapShapeLayer>
       </map:SfMaps.Layer>
    </map:SfMaps>
    SfMaps maps = new SfMaps();
    MapShapeLayer layer = new MapShapeLayer();
    RangeViewModel rangeViewModel = new RangeViewModel();
    this.BindingContext = new RangeViewModel();
    layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
    layer.DataSource = rangeViewModel.WorldPopulationDensity;
    layer.ShapeDataField = "name";
    layer.PrimaryValuePath="CountryName";
    layer.ShowDataLabels = true;
    layer.DataLabelSettings = new MapDataLabelSettings()
    {
        DataLabelPath = "Density",
        OverflowMode = MapLabelOverflowMode.Trim,
        DataLabelStyle = new MapLabelStyle()
        {
            FontSize = 12,
            FontAttributes = FontAttributes.Italic,
            TextColor = Colors.Green
        },
    };
    maps.Layer = layer;
    this.Content = maps;
    
    // Model.
    public class CountryDensity
    {
        public string CountryName { get; set; }
        public double Density { get; set; }
    
        public CountryDensity(string countryName, double density)
        {
            this.CountryName = countryName;
            this.Density = density;
        }
    }
    
    // View Model.
    public class RangeViewModel
    {
        public ObservableCollection<CountryDensity> WorldPopulationDensity { get; set; }
    
        public RangeViewModel()
        {
            WorldPopulationDensity = new ObservableCollection<CountryDensity>()
            {
               new CountryDensity("Monaco", 19341),
               new CountryDensity("Macao", 21055),
               new CountryDensity("Singapore", 8041),
               new CountryDensity("Hong kong", 6677),
               new CountryDensity("China", 149)
            };
        }
    }    

    Constructors

    MapDataLabelSettings()

    Initializes a new instance of the MapDataLabelSettings class.

    Declaration
    public MapDataLabelSettings()

    Fields

    DataLabelPathProperty

    Identifies the DataLabelPath dependency property.

    Declaration
    public static readonly BindableProperty DataLabelPathProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for DataLabelPath dependency property.

    DataLabelStyleProperty

    Identifies the DataLabelStyle dependency property.

    Declaration
    public static readonly BindableProperty DataLabelStyleProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for DataLabelStyle dependency property.

    OverflowModeProperty

    Identifies the OverflowMode dependency property.

    Declaration
    public static readonly BindableProperty OverflowModeProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for OverflowMode dependency property.

    Properties

    DataLabelPath

    Gets or sets the field value to be fetched from data for each shape used to determine the data label in the shape layer of the maps.

    Declaration
    public string DataLabelPath { get; set; }
    Property Value
    Type Description
    System.String

    The data label path of the shapes. The default is null.

    Examples
    • XAML
    • C#
    <map:SfMaps>
       <map:SfMaps.BindingContext>
           <local:RangeViewModel/>
       </map:SfMaps.BindingContext>
       <map:SfMaps.Layer>
          <map:MapShapeLayer x:Name="layer"
                             ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json"
                             DataSource="{Binding WorldPopulationDensity}"
                             ShapeDataField="name"
                             PrimaryValuePath="CountryName"
                             ShowDataLabels="True">
    
             <map:MapShapeLayer.DataLabelSettings>
                 <map:MapDataLabelSettings DataLabelPath="Density"/>
             </map:MapShapeLayer.DataLabelSettings>
    
          </map:MapShapeLayer>
       </map:SfMaps.Layer>
    </map:SfMaps>
    SfMaps maps = new SfMaps();
    MapShapeLayer layer = new MapShapeLayer();
    RangeViewModel rangeViewModel = new RangeViewModel();
    this.BindingContext = new RangeViewModel();
    layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
    layer.DataSource = rangeViewModel.WorldPopulationDensity;
    layer.ShapeDataField = "name";
    layer.PrimaryValuePath="CountryName";
    layer.ShowDataLabels = true;
    layer.DataLabelSettings = new MapDataLabelSettings()
    {
        DataLabelPath = "Density"
    };
    maps.Layer = layer;
    this.Content = maps;

    DataLabelStyle

    Gets or sets the map data label style to customize the appearance of the data labels.

    Declaration
    public MapLabelStyle DataLabelStyle { get; set; }
    Property Value
    Type Description
    MapLabelStyle

    Apply when customization required for data labels.

    Examples
    • XAML
    • C#
    <map:SfMaps>
       <map:SfMaps.BindingContext>
           <local:RangeViewModel/>
       </map:SfMaps.BindingContext>
       <map:SfMaps.Layer>
          <map:MapShapeLayer x:Name="layer"
                             ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json"
                             DataSource="{Binding WorldPopulationDensity}"
                             ShapeDataField="name"
                             PrimaryValuePath="CountryName"
                             ShowDataLabels="True">
    
             <map:MapShapeLayer.DataLabelSettings>
                 <map:MapDataLabelSettings DataLabelPath="Density">
    
                    <map:MapDataLabelSettings.DataLabelStyle>
                        <map:MapLabelStyle TextColor="Green" 
                                           FontSize="12" 
                                           FontAttributes="Bold"/>
                    </map:MapDataLabelSettings.DataLabelStyle>
    
                 </map:MapDataLabelSettings>
             </map:MapShapeLayer.DataLabelSettings>
    
          </map:MapShapeLayer>
       </map:SfMaps.Layer>
    </map:SfMaps>
    SfMaps maps = new SfMaps();
    MapShapeLayer layer = new MapShapeLayer();
    RangeViewModel rangeViewModel = new RangeViewModel();
    this.BindingContext = new RangeViewModel();
    layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
    layer.DataSource = rangeViewModel.WorldPopulationDensity;
    layer.ShapeDataField = "name";
    layer.PrimaryValuePath="CountryName";
    layer.ShowDataLabels = true;
    layer.DataLabelSettings = new MapDataLabelSettings()
    {
        DataLabelPath = "Density",
        DataLabelStyle = new MapLabelStyle()
        {
            FontSize = 12,
            FontAttributes = FontAttributes.Bold,
            TextColor = Colors.Green
        },
    };
    maps.Layer = layer;
    this.Content = maps;

    OverflowMode

    Gets or sets the label intersection action.

    Declaration
    public MapLabelOverflowMode OverflowMode { get; set; }
    Property Value
    Type Description
    MapLabelOverflowMode

    One of the enumeration values that specifies the over flow mode of data label. The default is None.

    Examples
    • XAML
    • C#
    <map:SfMaps>
       <map:SfMaps.BindingContext>
           <local:RangeViewModel/>
       </map:SfMaps.BindingContext>
       <map:SfMaps.Layer>
          <map:MapShapeLayer x:Name="layer"
                             ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json"
                             DataSource="{Binding WorldPopulationDensity}"
                             ShapeDataField="name"
                             PrimaryValuePath="CountryName"
                             ShowDataLabels="True">
    
             <map:MapShapeLayer.DataLabelSettings>
                 <map:MapDataLabelSettings DataLabelPath="Density"
                                           OverflowMode="Trim">
    
                    <map:MapDataLabelSettings.DataLabelStyle>
                        <map:MapLabelStyle TextColor="Green" 
                                           FontSize="12" 
                                           FontAttributes="Bold" />
                    </map:MapDataLabelSettings.DataLabelStyle>
    
                 </map:MapDataLabelSettings>
             </map:MapShapeLayer.DataLabelSettings>
    
          </map:MapShapeLayer>
       </map:SfMaps.Layer>
    </map:SfMaps>
    SfMaps maps = new SfMaps();
    MapShapeLayer layer = new MapShapeLayer();
    RangeViewModel rangeViewModel = new RangeViewModel();
    this.BindingContext = new RangeViewModel();
    layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
    layer.DataSource = rangeViewModel.WorldPopulationDensity;
    layer.ShapeDataField = "name";
    layer.PrimaryValuePath="CountryName";
    layer.ShowDataLabels = true;
    layer.DataLabelSettings = new MapDataLabelSettings()
    {
        DataLabelPath = "Density",
        OverflowMode = MapLabelOverflowMode.Trim,
        DataLabelStyle = new MapLabelStyle()
        {
            FontSize = 12,
            FontAttributes = FontAttributes.Bold,
            TextColor = Colors.Green
        },
    };
    maps.Layer = layer;
    this.Content = maps;

    Methods

    OnBindingContextChanged()

    Invoked whenever the binding context of the View changes.

    Declaration
    protected override void OnBindingContextChanged()
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved