as method

num as(
  1. LengthUnit unit,
  2. GeoLatLng p1,
  3. GeoLatLng p2
)

Converts the distance to the given LengthUnit

final int km = distance.as(LengthUnit.Kilometer,
    new LatLng(52.518611,13.408056),new LatLng(51.519475,7.46694444));

Implementation

num as(final LengthUnit unit, final GeoLatLng p1, final GeoLatLng p2) {
  final double dist = _calculator.distance(p1, p2).toDouble();
  return _round(LengthUnit.Meter.to(unit, dist));
}