Back to Devexpress

MapPolygon Class

windowsforms-devexpress-dot-xtramap-776cd299.md

latest3.9 KB
Original Source

MapPolygon Class

The class used to draw a polygon on a map.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
public class MapPolygon :
    MapShape,
    ISupportCoordPoints,
    IPolygonCore,
    IPointContainerCore,
    IEditableItem,
    ISimplifiableItem
vb
Public Class MapPolygon
    Inherits MapShape
    Implements ISupportCoordPoints,
               IPolygonCore,
               IPointContainerCore,
               IEditableItem,
               ISimplifiableItem

The following members return MapPolygon objects:

Remarks

The following image shows an example of a map polygon object.

Note that, a map shape should fulfill the following condition to cross the 180th meridian: one or several points’ longitudes should exceed the 180 (-180) limit:

csharp
MapPolygon polygon = new MapPolygon();
polygon.Points.Add(new GeoPoint(10, -170));
polygon.Points.Add(new GeoPoint(10, 170));
polygon.Points.Add(new GeoPoint(-10, 170));
polygon.Points.Add(new GeoPoint(-10, -170));
vectorItemStorage.Items.Add(polygon);

// Point longitudes enclose the 180 meridian.
MapPolygon polygonCross180 = New MapPolygon();
polygonCross180.Fill = Color.Orange;
polygonCross180.Points.Add(new GeoPoint(30, 190));
polygonCross180.Points.Add(new GeoPoint(30, 170));
polygonCross180.Points.Add(new GeoPoint(20, 170));
polygonCross180.Points.Add(new GeoPoint(20, 190));
vectorItemStorage.Items.Add(polygon180);
vb
Dim polygon = New MapPolygon
polygon.Points.Add(New GeoPoint(10, -170))
polygon.Points.Add(New GeoPoint(10, 170))
polygon.Points.Add(New GeoPoint(-10, 170))
polygon.Points.Add(New GeoPoint(-10, -170))
vectorItemStorage.Items.Add(polygon)

' Point longitudes enclose the 180 meridian.
Dim polygonCross180 = New MapPolygon
polygonCross180.Fill = Color.Orange
polygonCross180.Points.Add(New GeoPoint(30, 190))
polygonCross180.Points.Add(New GeoPoint(30, 170))
polygonCross180.Points.Add(New GeoPoint(20, 170))
polygonCross180.Points.Add(New GeoPoint(20, 190))
vectorItemStorage.Items.Add(polygonCross180)

The code above produces the following image:

Example

View Example

csharp
var polygon = new MapPolygon();
polygon.Points.AddRange(new GeoPoint[] {
    new GeoPoint(70,80),
    new GeoPoint(75,90),
    new GeoPoint(75,130)
});
ItemStorage.Items.Add(polygon);
vb
Dim polygon = New MapPolygon()
polygon.Points.AddRange(New GeoPoint() {New GeoPoint(70, 80), New GeoPoint(75, 90), New GeoPoint(75, 130)})
ItemStorage.Items.Add(polygon)

Implements

IColorizerElement

IEditableItem

Inheritance

Object MapItem MapShape MapPolygon

See Also

MapPolygon Members

Vector Items

DevExpress.XtraMap Namespace