So far, we've taken for granted that we will zoom in/out when clicking on plus or minus buttons. We haven't discussed much about what actually is behind the map interaction when you use buttons. The ol.control namespace contains numerous classes that make our maps interactive, in particular to configure behavior on your map. There are many built-in controls, each with their own unique functions. You can easily customize them with a CSS style or other parameters. Contrary to interactions, controls depend on DOM elements and not keyboard and mouse input only.
In this chapter, we'll cover the following topics:
ol.control classes and their organizationControls allow us to interact with our map. They also allow us to display extra information, such as displaying a scale bar with the ol.control.ScaleLine control. Before, in the previous generation of OpenLayers, version 2.x, some controls did not have a visual appearance. Nowadays, those elements, which do not rely on a DOM element, are called interactions like for example, touch interactions on mobiles. You can have as many controls on your map as you'd like. There are even some cases where you may not want any controls—such as embedding an unmovable map in a page, or showing a static map for printing.