O'Reilly logo

OpenLayers 3 : Beginner's Guide by Erik Hazzard, Paul Spencer, Thomas Gratier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding controls to your map

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 same addControl().

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required