examples/measure.js
function(polygon) {
  const area = getArea(polygon);
  let output;
  if (area > 10000) {
    output = (Math.round(area / 1000000 * 100) / 100) +
        ' ' + 'km<sup>2</sup>';
  } else {
    output = (Math.round(area * 100) / 100) +
        ' ' + 'm<sup>2</sup>';
  }
  return output;
}
function(polygon) {
  const area = getArea(polygon);
  let output;
  if (area > 10000) {
    output = (Math.round(area / 1000000 * 100) / 100) +
        ' ' + 'km<sup>2</sup>';
  } else {
    output = (Math.round(area * 100) / 100) +
        ' ' + 'm<sup>2</sup>';
  }
  return output;
}
function ( polygon ) { const area = getArea ( polygon ) ; let output ; if ( area > 10000 ) { output = ( Math . round ( area / 1000000 * 100 ) / 100 ) + ' ' + 'km<sup>2</sup>' ; } else { output = ( Math . round ( area * 100 ) / 100 ) + ' ' + 'm<sup>2</sup>' ; } return output ; }
Format area output.
@param {Polygon} polygon The polygon.
@return {string} Formatted area.
Format area output .