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

Events


An event basically means what it sounds like—something happening. Really, all user input is an event—a key press, a mouse click, etc. are all events.

Using JavaScript, we're able to access user generated events, such as a mouse click, and do things when an event occurs. Events are what drive the interaction in OpenLayers—when you drag the map, you are actually issuing a mouse event that OpenLayers interprets and then updates the map accordingly.

OpenLayers has its own Event class which makes interacting with events easier, and even enables us to create our own custom events. We won't get much into that right now, but we should briefly talk about something known as event handlers.

Event listeners and handlers

If you understood the previous paragraphs, then you may be able to guess what an event handler (and listener) is. In essence, an event listener is something that listens for events, and an event handler is something that responds to an event.

Consider the button control we created...