Back to Devexpress

GeoUtils.CalculateArea(MapShape) Method

wpf-devexpress-dot-xpf-dot-map-dot-geoutils-dot-calculatearea-x28-devexpress-dot-xpf-dot-map-dot-mapshape-x29.md

latest2.4 KB
Original Source

GeoUtils.CalculateArea(MapShape) Method

Computes the closed shape area.

Namespace : DevExpress.Xpf.Map

Assembly : DevExpress.Xpf.Map.v25.2.dll

NuGet Package : DevExpress.Wpf.Map

Declaration

csharp
public static double CalculateArea(
    MapShape shape
)
vb
Public Shared Function CalculateArea(
    shape As MapShape
) As Double

Parameters

NameTypeDescription
shapeMapShape

The closed map shape whose area is calculated.

|

Returns

TypeDescription
Double

The map shape area in squire meters.

|

Remarks

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 when the MapControl.SelectionChanged event occurs:

csharp
private void MapControl_SelectionChanged(object sender, MapItemSelectionChangedEventArgs e) {
    MapShape mapShape = vectorLayer.SelectedItems[0] as MapShape;
    double areaByShape = GeoUtils.CalculateArea(mapShape) / 1000000;            
    label.Content = $"Shape Area: {areaByShape:F2} km²";
}
vb
Private Sub MapControl_SelectionChanged(ByVal sender As Object, ByVal e As MapItemSelectionChangedEventArgs)
    Dim mapShape As MapShape = CType(vectorLayer.SelectedItems(0),MapShape)
    Dim areaByShape As Double = (GeoUtils.CalculateArea(mapShape) / 1000000)
    label.Content = "Shape Area: {areaByShape:F2} km²"
End Sub

See Also

GeoUtils Class

GeoUtils Members

DevExpress.Xpf.Map Namespace