isOverlapping method

bool isOverlapping(
  1. LatLngBounds other
)

Checks whether at least one edge of the other bounding box is overlapping with this bounding box.

Bounding boxes that touch each other but don't overlap are counted as not overlapping.

Implementation

bool isOverlapping(LatLngBounds other) {
  if (south > other.north || north < other.south) {
    return false;
  }
  if (longitudeWidth >= 360 || other.longitudeWidth >= 360) {
    return true;
  }
  // TODO may not be relevant for projections without world replication
  var delta = longitudeCenter - other.longitudeCenter;
  while (delta >= 180) {
    delta -= 360;
  }
  while (delta <= -180) {
    delta += 360;
  }
  delta = delta.abs();
  return delta < (longitudeWidth + other.longitudeWidth) / 2;
}