Back to Devexpress

GeoUtils.CalculateStrokeLength(MapShape) Method

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

latest2.6 KB
Original Source

GeoUtils.CalculateStrokeLength(MapShape) Method

Returns the map shape’s stroke length in meters.

Namespace : DevExpress.Xpf.Map

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

NuGet Package : DevExpress.Wpf.Map

Declaration

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

Parameters

NameTypeDescription
shapeMapShape

The map shape whose stroke length should be calculated.

|

Returns

TypeDescription
Double

The map shape stroke length in meters.

|

Remarks

You can use the CalculateStrokeLength method to determine the stroke length of the following vector items:

The following code computes a selected map item’s stroke length when the MapControl.SelectionChanged event occurs:

csharp
private void MapControl_SelectionChanged(object sender, MapItemSelectionChangedEventArgs e) {
    MapShape mapShape = vectorLayer.SelectedItems[0] as MapShape;
    double strokeLength = GeoUtils.CalculateStrokeLength(mapShape);
    label.Content = $"StokeLength: {strokeLength / 1000: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 strokeLength As Double = GeoUtils.CalculateStrokeLength(mapShape)
    label.Content = "StokeLength: {strokeLength / 1000:F2} km"
End Sub

See Also

GeoUtils Class

GeoUtils Members

DevExpress.Xpf.Map Namespace