Class MapLegend
Represents the map legend to show legend for the bubbles or shapes.
Information provided in the legend helps to identify the data rendered in the map shapes or bubbles.
Inheritance
Namespace: Syncfusion.Maui.Maps
Assembly: Syncfusion.Maui.Maps.dll
Syntax
public class MapLegend : BindableObject, ILegend
Examples
<map:SfMaps>
<map:SfMaps.BindingContext>
<local:BubbleViewModel/>
</map:SfMaps.BindingContext>
<map:SfMaps.Layer>
<map:MapShapeLayer x:Name="layer"
ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json"
DataSource="{Binding Details}"
ShapeDataField="name"
PrimaryValuePath="CountryName"
ShowBubbles="True">
<map:MapShapeLayer.BubbleSettings>
<map:MapBubbleSettings SizeValuePath="UsersCount"
ColorValuePath="UserCount">
<map:MapBubbleSettings.ColorMappings>
<map:RangeColorMapping Color="#809fff" From="0" To="100" Text="0-100" />
<map:RangeColorMapping Color="#3366ff" From="100" To="200" Text="100-200" />
<map:RangeColorMapping Color="#0039e6" From="200" To="300" Text="200-300" />
</map:MapBubbleSettings.ColorMappings>
</map:MapShapeLayer.BubbleSettings>
<map:MapShapeLayer.Legend>
<map:MapLegend Placement="Bottom"
SourceType="Bubble">
<map:MapLegend.TextStyle>
<map:MapLabelStyle TextColor="Green"
FontSize="12"
FontAttributes="Bold" />
</map:MapLegend.TextStyle>
</map:MapLegend>
</map:MapShapeLayer.Legend>
</map:MapShapeLayer>
</map:SfMaps.Layer>
</map:SfMaps>
Constructors
MapLegend()
Initializes a new instance of the MapLegend class.
Declaration
public MapLegend()
Fields
IconSizeProperty
Identifies the IconSize dependency property.
Declaration
public static readonly BindableProperty IconSizeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for IconSize dependency property. |
IconTypeProperty
Identifies the IconType dependency property.
Declaration
public static readonly BindableProperty IconTypeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for IconType dependency property. |
PlacementProperty
Identifies the Placement dependency property.
Declaration
public static readonly BindableProperty PlacementProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for Placement dependency property. |
SourceTypeProperty
Identifies the SourceType dependency property.
Declaration
public static readonly BindableProperty SourceTypeProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for SourceType dependency property. |
TextStyleProperty
Identifies the TextStyle dependency property.
Declaration
public static readonly BindableProperty TextStyleProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for TextStyle dependency property. |
Properties
IconSize
Gets or sets the icon size of legend.
Declaration
public Size IconSize { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Graphics.Size | It specifies the size of the legend.The default value is Height=12, Width=12. |
Examples
<map:SfMaps>
<map:SfMaps.Layer>
<map:MapShapeLayer x:Name="layer"
ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json"
DataSource="{Binding Details}"
ShapeDataField="name"
PrimaryValuePath="CountryName"
ShowBubbles="True">
<map:MapShapeLayer.BubbleSettings>
<map:MapBubbleSettings SizeValuePath="UsersCount"
ColorValuePath="UserCount">
<map:MapBubbleSettings.ColorMappings>
<map:RangeColorMapping Color="#809fff" From="0" To="100" Text="0-100" />
<map:RangeColorMapping Color="#3366ff" From="100" To="200" Text="100-200" />
<map:RangeColorMapping Color="#0039e6" From="200" To="300" Text="200-300" />
</map:MapBubbleSettings.ColorMappings>
</map:MapShapeLayer.BubbleSettings>
<map:MapShapeLayer.Legend>
<map:MapLegend Placement="Bottom"
SourceType="Bubble"
IconSize="20,20"/>
</map:MapShapeLayer.Legend>
</map:MapShapeLayer>
</map:SfMaps.Layer>
</map:SfMaps>
IconType
Gets or sets the icon type of legend.
Declaration
public ShapeType IconType { get; set; }
Property Value
Type | Description |
---|---|
ShapeType | One of the enumeration values that specifies the icon type of legend. The default is Rectangle. |
Examples
<map:SfMaps>
<map:SfMaps.Layer>
<map:MapShapeLayer x:Name="layer"
ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json"
DataSource="{Binding Details}"
ShapeDataField="name"
PrimaryValuePath="CountryName"
ShowBubbles="True">
<map:MapShapeLayer.BubbleSettings>
<map:MapBubbleSettings SizeValuePath="UsersCount"
ColorValuePath="UserCount">
<map:MapBubbleSettings.ColorMappings>
<map:RangeColorMapping Color="#809fff" From="0" To="100" Text="0-100" />
<map:RangeColorMapping Color="#3366ff" From="100" To="200" Text="100-200" />
<map:RangeColorMapping Color="#0039e6" From="200" To="300" Text="200-300" />
</map:MapBubbleSettings.ColorMappings>
</map:MapShapeLayer.BubbleSettings>
<map:MapShapeLayer.Legend>
<map:MapLegend Placement="Bottom"
SourceType="Bubble"
IconSize="20,20"
IconType="Diamond"/>
</map:MapShapeLayer.Legend>
</map:MapShapeLayer>
</map:SfMaps.Layer>
</map:SfMaps>
Placement
Gets or sets the placement position of the legend.
Declaration
public LegendPlacement Placement { get; set; }
Property Value
Type | Description |
---|---|
LegendPlacement | One of the enumeration values that specifies the placement of legend. The default is Top. |
Examples
<map:SfMaps>
<map:SfMaps.Layer>
<map:MapShapeLayer x:Name="layer"
ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json"
DataSource="{Binding Details}"
ShapeDataField="name"
PrimaryValuePath="CountryName"
ShowBubbles="True">
<map:MapShapeLayer.BubbleSettings>
<map:MapBubbleSettings SizeValuePath="UsersCount"
ColorValuePath="UserCount">
<map:MapBubbleSettings.ColorMappings>
<map:RangeColorMapping Color="#809fff" From="0" To="100" Text="0-100" />
<map:RangeColorMapping Color="#3366ff" From="100" To="200" Text="100-200" />
<map:RangeColorMapping Color="#0039e6" From="200" To="300" Text="200-300" />
</map:MapBubbleSettings.ColorMappings>
</map:MapShapeLayer.BubbleSettings>
<map:MapShapeLayer.Legend>
<map:MapLegend Placement="Bottom"
SourceType="Bubble" />
</map:MapShapeLayer.Legend>
</map:MapShapeLayer>
</map:SfMaps.Layer>
</map:SfMaps>
SourceType
Gets or sets the source type of the legend that determines for which map element the legend need to be render.
Declaration
public LegendSourceType SourceType { get; set; }
Property Value
Type | Description |
---|---|
LegendSourceType | One of the enumeration values that specifies the source type of map legend. The default is Shape. |
Examples
<map:SfMaps>
<map:SfMaps.Layer>
<map:MapShapeLayer x:Name="layer"
ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json"
DataSource="{Binding Details}"
ShapeDataField="name"
PrimaryValuePath="CountryName"
ShowBubbles="True">
<map:MapShapeLayer.BubbleSettings>
<map:MapBubbleSettings SizeValuePath="UsersCount"
ColorValuePath="UserCount">
<map:MapBubbleSettings.ColorMappings>
<map:RangeColorMapping Color="#809fff" From="0" To="100" Text="0-100" />
<map:RangeColorMapping Color="#3366ff" From="100" To="200" Text="100-200" />
<map:RangeColorMapping Color="#0039e6" From="200" To="300" Text="200-300" />
</map:MapBubbleSettings.ColorMappings>
</map:MapShapeLayer.BubbleSettings>
<map:MapShapeLayer.Legend>
<map:MapLegend Placement="Bottom"
SourceType="Bubble" />
</map:MapShapeLayer.Legend>
</map:MapShapeLayer>
</map:SfMaps.Layer>
</map:SfMaps>
TextStyle
Gets or sets the label style to customize the appearance of the legend labels.
Declaration
public MapLabelStyle TextStyle { get; set; }
Property Value
Type | Description |
---|---|
MapLabelStyle | Apply when customization required for legend labels. |
Examples
<map:SfMaps>
<map:SfMaps.Layer>
<map:MapShapeLayer x:Name="layer"
ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json">
DataSource="{Binding Details}"
ShapeDataField="name"
PrimaryValuePath="CountryName"
ShowBubbles="True">
<map:MapShapeLayer.BubbleSettings>
<map:MapBubbleSettings SizeValuePath="UsersCount"
ColorValuePath="UserCount">
<map:MapBubbleSettings.ColorMappings>
<map:RangeColorMapping Color="#809fff" From="0" To="100" Text="0-100" />
<map:RangeColorMapping Color="#3366ff" From="100" To="200" Text="100-200" />
<map:RangeColorMapping Color="#0039e6" From="200" To="300" Text="200-300" />
</map:MapBubbleSettings.ColorMappings>
</map:MapShapeLayer.BubbleSettings>
<map:MapShapeLayer.Legend>
<map:MapLegend Placement="Bottom"
SourceType="Bubble"
IconSize="20,20"
IconType="Diamond">
<map:MapLegend.TextStyle>
<map:MapLabelStyle TextColor="Green"
FontSize="12"
FontAttributes="Bold" />
</map:MapLegend.TextStyle>
</map:MapLegend>
</map:MapShapeLayer.Legend>
</map:MapShapeLayer>
</map:SfMaps.Layer>
</map:SfMaps>
Methods
OnBindingContextChanged()
Invoked whenever the binding context of the View changes.
Declaration
protected override void OnBindingContextChanged()