Programmatically Add Layer
General API samples
This sample (specifically the sample code) shows how to programmatically create and add a layers.