O'Reilly logo

OpenLayers Cookbook by Antonio Santiago Perez

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 and removing controls

OpenLayers offers a great number of controls, commonly used on mapping applications.

This recipe shows how to use the most common controls that have a visual representation. The list includes the OverviewMap control, the Scale and ScaleLine controls, the Graticule control, the LayerSwitcher control, the PanZoomBar control, the MousePosition control, and the Permalink control:

Adding and removing controls

How to do it...

  1. First add the code for the buttons:
    <button data-dojo-type="dijit.form.ToggleButton" data-dojo-props="iconClass:'dijitCheckBoxIcon', checked: true, onChange: layerSwitcherChanged">LayerSwitcher</button> <button data-dojo-type="dijit.form.ToggleButton" ...

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