MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class MapPolygon

    Show / Hide Table of Contents

    Class MapPolygon

    The MapPolygon represents the default model for polygon layer.

    Inheritance
    System.Object
    MapPolygon
    Namespace: Syncfusion.Maui.Maps
    Assembly: Syncfusion.Maui.Maps.dll
    Syntax
    public class MapPolygon : BindableObject
    Examples
    • XAML
    • C#
     <map:SfMaps>
         <map:SfMaps.Layer>
              <map:MapShapeLayer ShapesSource = "https://cdn.syncfusion.com/maps/map-data/world-map.json">
                 <map:MapShapeLayer.Sublayers>
                     <map:MapPolygonLayer>
                         <map:MapPolygonLayer.Polygons>
                             <map:MapPolygon Fill = "LightGreen"
                                             Stroke="Green"
                                             StrokeThickness="4">
                                 <map:MapPolygon.Points>
                                     <map:MapLatLng Latitude="5.562764"
                                                    Longitude="101.470795" />
                                     <map:MapLatLng Latitude="-19.138292"
                                                    Longitude="44.822302" />
                                     <map:MapLatLng Latitude="-23.391278"
                                                    Longitude="124.580986" />
                                 </map:MapPolygon.Points>
                             </map:MapPolygon>
                         </map:MapPolygonLayer.Polygons>
                     </map:MapPolygonLayer>
                 </map:MapShapeLayer.Sublayers>
             </map:MapShapeLayer>
         </map:SfMaps.Layer>
     </map:SfMaps>
    SfMaps maps = new SfMaps();
    MapShapeLayer layer = new MapShapeLayer();
    layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
    MapPolygonLayer mapPolygonLayer = new MapPolygonLayer();
    MapPolygon polygon = new MapPolygon();
    polygon.Points = new ObservableCollection<MapLatLng>()
    {
       new MapLatLng(5.562764, 101.470795),
       new MapLatLng(-19.138292, 44.822302),
       new MapLatLng(-23.391278, 124.580986)
    };
    polygon.Fill = Brush.LightGreen;
    polygon.Stroke = Brush.Green;
    polygon.StrokeThickness = 4;
    mapPolygonLayer.Polygons.Add(polygon);
    layer.Sublayers.Add(mapPolygonLayer);
    maps.Layer = layer;
    this.Content = maps;

    Constructors

    MapPolygon()

    Initializes a new instance of the MapPolygon class.

    Declaration
    public MapPolygon()
    Examples
    • XAML
    • C#
     <map:SfMaps>
         <map:SfMaps.Layer>
              <map:MapShapeLayer ShapesSource = "https://cdn.syncfusion.com/maps/map-data/world-map.json">
                 <map:MapShapeLayer.Sublayers>
                     <map:MapPolygonLayer>
                         <map:MapPolygonLayer.Polygons>
                             <map:MapPolygon Fill = "LightGreen"
                                             Stroke="Green"
                                             StrokeThickness="4">
                                 <map:MapPolygon.Points>
                                     <map:MapLatLng Latitude="5.562764"
                                                    Longitude="101.470795" />
                                     <map:MapLatLng Latitude="-19.138292"
                                                    Longitude="44.822302" />
                                     <map:MapLatLng Latitude="-23.391278"
                                                    Longitude="124.580986" />
                                 </map:MapPolygon.Points>
                             </map:MapPolygon>
                         </map:MapPolygonLayer.Polygons>
                     </map:MapPolygonLayer>
                 </map:MapShapeLayer.Sublayers>
             </map:MapShapeLayer>
         </map:SfMaps.Layer>
     </map:SfMaps>
    SfMaps maps = new SfMaps();
    MapShapeLayer layer = new MapShapeLayer();
    layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
    MapPolygonLayer mapPolygonLayer = new MapPolygonLayer();
    MapPolygon polygon = new MapPolygon();
    polygon.Points = new ObservableCollection<MapLatLng>()
    {
       new MapLatLng(5.562764, 101.470795),
       new MapLatLng(-19.138292, 44.822302),
       new MapLatLng(-23.391278, 124.580986)
    };
    polygon.Fill = Brush.LightGreen;
    polygon.Stroke = Brush.Green;
    polygon.StrokeThickness = 4;
    mapPolygonLayer.Polygons.Add(polygon);
    layer.Sublayers.Add(mapPolygonLayer);
    maps.Layer = layer;
    this.Content = maps;

    Fields

    FillProperty

    Identifies the Fill bindable property.

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

    PointsProperty

    Identifies the Points bindable property.

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

    StrokeProperty

    Identifies the Stroke bindable property.

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

    StrokeThicknessProperty

    Identifies the StrokeThickness bindable property.

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

    Properties

    Fill

    Gets or sets the brush that paints the interior area of the polygon.

    Declaration
    public Brush Fill { get; set; }
    Property Value
    Type Description
    Microsoft.Maui.Controls.Brush

    A Brush that specifies how the map polygon interior is painted.

    Examples
    • XAML
    • C#
     <map:SfMaps>
         <map:SfMaps.Layer>
              <map:MapShapeLayer ShapesSource = "https://cdn.syncfusion.com/maps/map-data/world-map.json">
                 <map:MapShapeLayer.Sublayers>
                     <map:MapPolygonLayer>
                         <map:MapPolygonLayer.Polygons>
                             <map:MapPolygon Fill = "LightGreen">
                                 <map:MapPolygon.Points>
                                     <map:MapLatLng Latitude="5.562764"
                                                    Longitude="101.470795" />
                                     <map:MapLatLng Latitude="-19.138292"
                                                    Longitude="44.822302" />
                                     <map:MapLatLng Latitude="-23.391278"
                                                    Longitude="124.580986" />
                                 </map:MapPolygon.Points>
                             </map:MapPolygon>
                         </map:MapPolygonLayer.Polygons>
                     </map:MapPolygonLayer>
                 </map:MapShapeLayer.Sublayers>
             </map:MapShapeLayer>
         </map:SfMaps.Layer>
     </map:SfMaps>
    SfMaps maps = new SfMaps();
    MapShapeLayer layer = new MapShapeLayer();
    layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
    MapPolygonLayer mapPolygonLayer = new MapPolygonLayer();
    MapPolygon polygon = new MapPolygon();
    polygon.Points = new ObservableCollection<MapLatLng>()
    {
       new MapLatLng(5.562764, 101.470795),
       new MapLatLng(-19.138292, 44.822302),
       new MapLatLng(-23.391278, 124.580986)
    };
    polygon.Fill = Brush.LightGreen;
    mapPolygonLayer.Polygons.Add(polygon);
    layer.Sublayers.Add(mapPolygonLayer);
    maps.Layer = layer;
    this.Content = maps;

    Points

    Gets or sets the collection of geolocation coordinates of the polygon to be drawn.

    Declaration
    public IList<MapLatLng> Points { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.IList<MapLatLng>

    The points collection. By default, the collection is empty.

    Examples
    • XAML
    • C#
     <map:SfMaps>
         <map:SfMaps.Layer>
              <map:MapShapeLayer ShapesSource = "https://cdn.syncfusion.com/maps/map-data/world-map.json">
                 <map:MapShapeLayer.Sublayers>
                     <map:MapPolygonLayer>
                         <map:MapPolygonLayer.Polygons>
                             <map:MapPolygon>
                                 <map:MapPolygon.Points>
                                     <map:MapLatLng Latitude="5.562764"
                                                    Longitude="101.470795" />
                                     <map:MapLatLng Latitude="-19.138292"
                                                    Longitude="44.822302" />
                                     <map:MapLatLng Latitude="-23.391278"
                                                    Longitude="124.580986" />
                                 </map:MapPolygon.Points>
                             </map:MapPolygon>
                         </map:MapPolygonLayer.Polygons>
                     </map:MapPolygonLayer>
                 </map:MapShapeLayer.Sublayers>
             </map:MapShapeLayer>
         </map:SfMaps.Layer>
     </map:SfMaps>
    SfMaps maps = new SfMaps();
    MapShapeLayer layer = new MapShapeLayer();
    layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
    MapPolygonLayer mapPolygonLayer = new MapPolygonLayer();
    MapPolygon polygon = new MapPolygon();
    polygon.Points = new ObservableCollection<MapLatLng>()
    {
       new MapLatLng(5.562764, 101.470795),
       new MapLatLng(-19.138292, 44.822302),
       new MapLatLng(-23.391278, 124.580986)
    };
    mapPolygonLayer.Polygons.Add(polygon);
    layer.Sublayers.Add(mapPolygonLayer);
    maps.Layer = layer;
    this.Content = maps;

    Stroke

    Gets or sets the brush that paints the stroke area of the polygon.

    Declaration
    public Brush Stroke { get; set; }
    Property Value
    Type Description
    Microsoft.Maui.Controls.Brush

    A Brush that specifies how the map polygon outline is painted.

    Examples
    • XAML
    • C#
     <map:SfMaps>
         <map:SfMaps.Layer>
              <map:MapShapeLayer ShapesSource = "https://cdn.syncfusion.com/maps/map-data/world-map.json">
                 <map:MapShapeLayer.Sublayers>
                     <map:MapPolygonLayer>
                         <map:MapPolygonLayer.Polygons>
                             <map:MapPolygon Fill = "LightGreen"
                                             Stroke="Green">
                                 <map:MapPolygon.Points>
                                     <map:MapLatLng Latitude="5.562764"
                                                    Longitude="101.470795" />
                                     <map:MapLatLng Latitude="-19.138292"
                                                    Longitude="44.822302" />
                                     <map:MapLatLng Latitude="-23.391278"
                                                    Longitude="124.580986" />
                                 </map:MapPolygon.Points>
                             </map:MapPolygon>
                         </map:MapPolygonLayer.Polygons>
                     </map:MapPolygonLayer>
                 </map:MapShapeLayer.Sublayers>
             </map:MapShapeLayer>
         </map:SfMaps.Layer>
     </map:SfMaps>
    SfMaps maps = new SfMaps();
    MapShapeLayer layer = new MapShapeLayer();
    layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
    MapPolygonLayer mapPolygonLayer = new MapPolygonLayer();
    MapPolygon polygon = new MapPolygon();
    polygon.Points = new ObservableCollection<MapLatLng>()
    {
       new MapLatLng(5.562764, 101.470795),
       new MapLatLng(-19.138292, 44.822302),
       new MapLatLng(-23.391278, 124.580986)
    };
    polygon.Fill = Brush.LightGreen;
    polygon.Stroke = Brush.Green;
    mapPolygonLayer.Polygons.Add(polygon);
    layer.Sublayers.Add(mapPolygonLayer);
    maps.Layer = layer;
    this.Content = maps;

    StrokeThickness

    Gets or sets the value that specifies the width of the polygon stroke outline.

    Declaration
    public double StrokeThickness { get; set; }
    Property Value
    Type Description
    System.Double

    It specifies the width of the map polygon stroke outline. The default value is 2.

    Examples
    • XAML
    • C#
     <map:SfMaps>
         <map:SfMaps.Layer>
              <map:MapShapeLayer ShapesSource = "https://cdn.syncfusion.com/maps/map-data/world-map.json">
                 <map:MapShapeLayer.Sublayers>
                     <map:MapPolygonLayer>
                         <map:MapPolygonLayer.Polygons>
                             <map:MapPolygon Fill = "LightGreen"
                                             Stroke="Green"
                                             StrokeThickness="4">
                                 <map:MapPolygon.Points>
                                     <map:MapLatLng Latitude="5.562764"
                                                    Longitude="101.470795" />
                                     <map:MapLatLng Latitude="-19.138292"
                                                    Longitude="44.822302" />
                                     <map:MapLatLng Latitude="-23.391278"
                                                    Longitude="124.580986" />
                                 </map:MapPolygon.Points>
                             </map:MapPolygon>
                         </map:MapPolygonLayer.Polygons>
                     </map:MapPolygonLayer>
                 </map:MapShapeLayer.Sublayers>
             </map:MapShapeLayer>
         </map:SfMaps.Layer>
     </map:SfMaps>
    SfMaps maps = new SfMaps();
    MapShapeLayer layer = new MapShapeLayer();
    layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
    MapPolygonLayer mapPolygonLayer = new MapPolygonLayer();
    MapPolygon polygon = new MapPolygon();
    polygon.Points = new ObservableCollection<MapLatLng>()
    {
       new MapLatLng(5.562764, 101.470795),
       new MapLatLng(-19.138292, 44.822302),
       new MapLatLng(-23.391278, 124.580986)
    };
    polygon.Fill = Brush.LightGreen;
    polygon.Stroke = Brush.Green;
    polygon.StrokeThickness = 4;
    mapPolygonLayer.Polygons.Add(polygon);
    layer.Sublayers.Add(mapPolygonLayer);
    maps.Layer = layer;
    this.Content = maps;
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved