equal method

  1. @override
bool equal(
  1. dynamic other, [
  2. dynamic maxMargin = 0.0001
])
override

Returns true if the given position is at the same position (within a small margin of error).

The margin of error can be overridden by setting maxMargin to a small number.

can accept other: LatLng(20.0, 30.0) or other: 20.0, 30.0

Implementation

@override
bool equal(other, [maxMargin = 0.0001]) {
  if (other == null) {
    return false;
  }

  LatLng o = LatLng.from(other);

  double margin = math.max(
    (lat - o.lat).abs(),
    (lng - o.lng).abs(),
  );

  margin = math.max(margin, (alt - o.alt).abs());

  return margin <= maxMargin;
}