generateLayer function

Generates a layer