• JMap.Geometry.getLineLength

    Works for feature having geometry equals to LineString or a MultiLineString.

    It returns the line length in the desired units (default in kilometers).

    Throw an error if the provided feature geometry is not a LineString or a MultiLineString.

    Parameters

    • feature: Feature<LineString, GeoJsonProperties> | Feature<MultiLineString, GeoJsonProperties>

      The LineString or MultiLineString feature to measure.

    • Optional units: JGEOMETRY_UNITS | JMAP_DISTANCE_UNITS

      Can be "degrees", "radians", "miles", or "kilometers" (default)

    Returns number

    Example

    const line = ...

    // The method will return the line length in kilometers
    JMap.Geometry.getLineLength(line)

    // The method will return the line length in miles
    JMap.Geometry.getLineLength(line, "miles")