windowsforms-devexpress-dot-xtramap-dot-geoutils-dot-calculatearea-x28-devexpress-dot-xtramap-dot-mapshape-x29.md
Computes the closed shape area.
Namespace : DevExpress.XtraMap
Assembly : DevExpress.XtraMap.v25.2.dll
NuGet Package : DevExpress.Win.Map
public static double CalculateArea(
MapShape shape
)
Public Shared Function CalculateArea(
shape As MapShape
) As Double
| Name | Type | Description |
|---|---|---|
| shape | MapShape |
The closed map shape whose area is calculated.
|
| Type | Description |
|---|---|
| Double |
The map shape area in squire meters.
|
You can use the CalculateArea method to determine an area of the following vector items:
The following example shows how to compute the selected map shape’s area:
private void mapControl_SelectionChanged(object sender, MapSelectionChangedEventArgs e) {
MapShape mapShape = vectorItemsLayer.SelectedItem as MapShape;
double areaByShape = GeoUtils.CalculateArea(mapShape)/1000000;
label.Text = $"Shape Area: {areaByShape:F2} km²";
}
Private Sub mapControl_SelectionChanged(ByVal sender As Object, ByVal e As MapSelectionChangedEventArgs)
Dim mapShape As MapShape = CType(vectorItemsLayer.SelectedItem,MapShape)
Dim areaByShape As Double = (GeoUtils.CalculateArea(mapShape) / 1000000)
label.Text = "Area: {areaByShape:F2} km²"
End Sub
See Also