@watergis/maplibre-gl-terradraw
    Preparing search index...
    • Convert elevation according to the unit type given.

      Converts elevation from meters to the appropriate unit based on the unit parameter. This function is used to display elevation values in the correct unit based on the measureUnitType setting in MaplibreMeasureControl.

      • For metric, returns value in meters with 'm' symbol.
      • For imperial, converts meters to feet using the conversion factor 1 meter = 3.28084 feet.

      Parameters

      • value: number

        The elevation value in meters (as returned by terrain queries).

      • unit: MeasureUnitType = 'metric'

        The unit type: "metric" or "imperial" (default is 'metric').

      • measureUnitSymbols: MeasureUnitSymbolType = defaultMeasureUnitSymbols

        Optional parameter to provide custom unit symbols. Uses defaultMeasureUnitSymbols if not provided.

      Returns { elevation: number; unit: string }

      An object containing the converted elevation value and the unit symbol string.

      // Convert 100 meters to metric display
      const metric = convertElevation(100, 'metric');
      // Returns: { elevation: 100, unit: 'm' }

      // Convert 100 meters to imperial display
      const imperial = convertElevation(100, 'imperial');
      // Returns: { elevation: 328.084, unit: 'ft' }