O'Reilly logo

OpenLayers 2.10 by Erik Hazzard

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

Creating a custom button

You know a bit more about the Button class now, so let's put that knowledge to use. We'll create a fairly simple custom button (of control type TYPE_BUTTON) that will update the base layer's opacity and zoom the map to a random spot. We'll cover the few basic things that should be included when creating a button:

  • Specifying the button's displayClass to give it style (optional)
  • Creating a function and setting it as the trigger function
  • Adding the button a panel, and then adding that panel to a map

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