code: private Coordinate checkPosition(final Coordinate newPosition, final double newResolution) {
  		double xCenter = newPosition.getX();
  		double yCenter = newPosition.getY();
  		if (maxBounds != null) {
  			double w = mapWidth * newResolution / 2;
  			double h = mapHeight * newResolution / 2;
  			Coordinate minCoordinate = BboxService.getOrigin(maxBounds);
  			Coordinate maxCoordinate = BboxService.getEndPoint(maxBounds);
  
  			if ((w * 2) > maxBounds.getWidth()) {
  				xCenter = BboxService.getCenterPoint(maxBounds).getX();
  			} else {
  				if ((xCenter - w) < minCoordinate.getX()) {
  					xCenter = minCoordinate.getX() + w;
  				}
  				if ((xCenter + w) > maxCoordinate.getX()) {
  					xCenter = maxCoordinate.getX() - w;
  				}
  			}
  			if ((h * 2) > maxBounds.getHeight()) {
  				yCenter = BboxService.getCenterPoint(maxBounds).getY();
  			} else {
  				if ((yCenter - h) < minCoordinate.getY()) {
  					yCenter = minCoordinate.getY() + h;
  				}
  				if ((yCenter + h) > maxCoordinate.getY()) {
  					yCenter = maxCoordinate.getY() - h;
  				}
  			}
  		}
  		return new Coordinate(xCenter, yCenter);
  	}
docs: Returns a position that's within the maximum bounds: