What is the difference between a Layer in Openlayers and an Overlay?
For example, If I have points that I want to show on a map, what are the pros/cons of displaying them either using a Vector Layer or an Overlay?
Thank you
Geographic vector data should almost always be displayed as a (vector) layer. Labels and other styling can be implemented via style definitions or style functions, even complex styles capable of showing more data if needed. Layers can be overlayed by other layers and overlays. Layers are very performant and capable of rendering many points.
Overlays are meant for HTML-Elements to be bound to a geographic coordinate. The main use cases are temporary popups, for instance information-boxes, that show after clicking on the map or features on the map. For that reason, Overlays will always lie above the map and it's layers and should be dismissable.
One pro of overlay is the connection to the DOM. Complex overlays can be designed with pure css and can contain any HTML Element, most often Images and links.
He is a classic example for using both, a vector layer for permanent data and a temporary overlay for displaying additional information after clicking the feature: https://openlayers.org/en/latest/examples/icon.html