There are two methods for adding controls to a map:
You can pass in a JavaScript array of
ol.control.*
objects when you instantiate the map object.You can add controls to the map object after it has been created by calling the map function's
addControl()
, method passing in a single control object. If you need to pass more than one control, just loop using an array of control objects, using the sameaddControl()
.
When you create your map, three control objects are added automatically. These three controls are as follows:
ol.control.Attribution
: This is responsible for displaying credits for producers of map data sources or tiles providers like for OpenStreetMap. By default, the control is located in the bottom-right corner.ol.control.Zoom
: This is responsible for showing the plus and minus buttons in the top-left corner. Those buttons when clicking help to do a zoom in for plus and a zoom out for minus.ol.control.Rotate
: This is responsible for resetting the map...