import MapLabel from './map-label';
import featureCenter from './feature-center';
import getMeasurement from './get-measurement';

export default function initMeasureLabel(result, map) {
  if (!result) {
    return;
  }

  if (result.mode === 'measure') {
    let center = featureCenter(result.feature);
    let measurement = getMeasurement(result.type, result.feature);
    result.label = new MapLabel(center, {
      defaultLabel: `${measurement.value} ${measurement.unit}`
    });

    if (map) {
      result.label.setMap(map);
    }
  }
}

import MapLabel from './map-label';
import featureCenter from './feature-center';
import getMeasurement from './get-measurement';

export default function initMeasureLabel(result, map) {
  if (!result) {
    return;
  }

  if (result.mode === 'measure') {
    let center = featureCenter(result.feature);
    let measurement = getMeasurement(result.type, result.feature);
    result.label = new MapLabel(center);
    result.label.label = `${measurement.value} ${measurement.unit}`;

    if (map) {
      result.label.setMap(map);
    }
  }
}

Fix measurement label not showing on first load
Fix measurement label not showing on first load

After importing the label didn't show up because `defaultLabel` option was removed
