as method

num as(
  1. LengthUnit unit,
  2. LatLng p1,
  3. LatLng 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 LatLng p1, final LatLng p2) {
    final double dist = _calculator.distance(p1,p2);
    return _round(LengthUnit.Meter.to(unit,dist));
}