calculateBoundingBox method

BoundingBox calculateBoundingBox(
  1. Dimension mapDimension
)

Calculates the bounding box of the given dimensions of the view. Scaling or focalPoint are NOT considered.

Implementation

BoundingBox calculateBoundingBox(Dimension mapDimension) {
  if (boundingBox != null && _lastMapDimension == mapDimension)
    return boundingBox!;
  Mappoint center = getCenter();
  double leftX = center.x - mapDimension.width / 2;
  double rightX = center.x + mapDimension.width / 2;
  double topY = center.y - mapDimension.height / 2;
  double bottomY = center.y + mapDimension.height / 2;
  boundingBox = BoundingBox(
      _projection
          .pixelYToLatitude(min(bottomY, _projection.mapsize.toDouble())),
      _projection.pixelXToLongitude(max(leftX, 0)),
      _projection.pixelYToLatitude(max(topY, 0)),
      _projection
          .pixelXToLongitude(min(rightX, _projection.mapsize.toDouble())));
  _leftUpper = Mappoint(leftX, topY);
  _lastMapDimension = mapDimension;
  return boundingBox!;
}