If you remember the description of layers, two main layers types are vector and raster. Some layers with specific ol.source
accept methods to access geographic features in your map. The map queries each of the specified layers for this information, but not all layers support this. Only layers that support querying for geographic features will return results.
Without going deep into explanation, think that for the vector, you are querying the features near the point where you've done the click. Whereas for raster, you ask a remote resource to get a position on the image and extrapolate from this position the features of the image.
We will first review how to work with a vector source and then with raster sources. Do not worry if you don't already understand everything: we will review some concepts in the chapters dedicated to layers in particular.
So, we will see first how to get features from vectors, then explore how to do it from the method...