-
Book Overview & Buying
-
Table Of Contents
OpenLayers 3.x Cookbook - Second Edition
By :
By default, all the controls are placed on the map. This way, controls, such as Zoom, Attribution, or MousePosition, are rendered on top of the map and over any layer. This is the default behavior, but OpenLayers is flexible enough to allow us to put controls outside the map. In this recipe (source code in ch05/ch05-controls-outside-map), we are going to create a map where the Zoom to Extent and Scale Line controls are placed outside the map and within the sidebar, as you can see in the following screenshot:

To learn how to customize where the map controls are placed, follow these steps:
Create an HTML file and add the OpenLayers dependencies and div to hold the map. In particular, create a div element for each control within the sidebar markup:
<div id="js-zoom-extent"></div> <div id="js-scale-line"></div>
Create a custom JavaScript file and instantiate the map instance with view and a raster tile layer with the Open Street...
Change the font size
Change margin width
Change background colour