Book Image

OpenLayers 2.10 Beginner's Guide

Book Image

OpenLayers 2.10 Beginner's Guide

Overview of this book

Table of Contents (18 chapters)
OpenLayers 2.10
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating our own controls


You're familiar (or perhaps fed up) with control descriptions by now. Let's make things a little more interesting and create our own control. Here's the plan:

  1. Quickly talk about the Button Control class.

  2. Create a Button control with custom functionality.

  3. Add the button to a panel.

  4. Viola! You just created your own custom control.

So, before we talk about creating a custom button, let's go over the Button subclass that we didn't cover in the section above, which we'll use to create our custom controls.

OpenLayers.Control.Button

There's not much to cover here really, as we've been over the base control class. There are two properties we need to discuss however—the type and displayClass property. We'll use these two properties when creating our own custom control.

Button properties

Name

Type

Description

Default Value

type

{Integer}

This is an integer which represents the type of control this button is. This is part of what we discussed earlier—the button types. OpenLayers...