OpenLayers is a JavaScript library, and as discussed earlier is built using Object Oriented Programming (OOP). When we want to actually create a layer, we will create (or instantiate) an object from an ol.layer.Layer subclass.
OpenLayers has many different ol.layer classes. The layer types are only for different kinds of data (tiles, images, and vector). Using an attached ol.source.* will allow you to connect to a different type of map server 'back end.' Each layer object is independent of other layer objects; so, doing things to one layer won't necessarily affect the other.
How many layers can I have?
The safest maximum amount of layers you can have on a map at one time depends largely on the user's machine (that is, their processing power and memory). Too many layers can also overwhelm users; many popular web maps (for example, Google and Yahoo!) contain just a few layers. We recommend that you don't use a lot of layers or limit the number of layers that you can turn on at the same time. Adding layers is cheap but making composition of the map image is expensive, particularly with Canvas renderer. If you turn on many layers at the same time, you will end up with an unusable map, whereas if only some of them are turned on, you will have good performance. You also need to be aware that using vector layers instead of raster layers is better for composition performances.
Whatever the purpose of your web map application is, you will need at least one layer to have a usable map. An OpenLayers map without any layers would be like an atlas without any maps. You need at least one layer—at least one base layer. All other layers that sit above the base layer are called overlay layers. The concept inherits from the existing OpenLayers 2 series and was seen in Chapter 1, Getting Started with OpenLayers.
A base layer is at the very bottom of the layer list, and all other layers are on top of it. This would be our printed map from the earlier example. The order of the other layers can change, but the base layer is always below the overlay layers. By default, the first layer that you add to your map acts as the base layer. You can, however, change the order of any layer on your map to act as the base layer.
You can also have multiple base layers. Although you can set more than one base layer active at a time, for visual readability, most of the time, you only use one.
Any layer that is not a base layer is called an overlay layer. Like we talked about earlier, the order that you add layers to your map is important. Every time you add a layer to the map, it is placed above the previous one.
After this reminder about layers concepts, see what's happening at the OpenLayers 3 library level inheritance to discover the main layers type.
There are two types of layers: raster and vector layers. The main differences between both are:
PNG or JPEG. They can be generated on server-side or are static. In most cases, your browser doesn't manipulate them but only consumes them.To give you an overview of layers organization at the library level, let's look at the following diagram:

When you are creating a new web mapping application, you have to make a choice between benefits and drawbacks of those layers. For raster, it's mainly that images do not overload the browser as vector layers mostly can. As you can see in the diagram, raster layers such as vector layers are derived from a common ol.layer.Layer class. This ol.layer.Layer class inherits from an ol.layer.Base class, (base in this case means common behavior between layers). This class is also inherited by an ol.layer.Group class designed to group layers to treat them as a single layer. In our case, we will focus mainly on the two raster layer classes, ol.layer.Image and ol.layer.Tile. We will also do a review of the common ol.layer.Layer methods. Moreover, you can divide raster in two categories: tiled or untiled. We will cover both types in this chapter. The ol.layer.Vector class will be covered in Chapter 5, Using Vector Layers.