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

Listening for non-OpenLayers events

When developing a web mapping application, the use of OpenLayers is only a piece among the set of tools that we need to use. Adding other components, such as buttons, images, lists, and so on, and interacting with them are other tasks that we must work on.

Interacting with a OpenLayers.Map instance or OpenLayers.Layer subclass is easy because they trigger specific events, but what if we want to listen for events on a button or any DOM element?

For this purpose, OpenLayers offers us the OpenLayers.Event class (do not get confused with the plural OpenLayers.Events class). This is a helper class, which, among other things, allows us to listen for events in non-OpenLayers elements in a browser-independent way.

Note ...

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