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 vector layer features' events

When working with vector layers, it is common to find a situation where you need to know what is happening, that is, when a new feature is going to be added to the layers or when a feature has been modified, deleted, and so on. Fortunately, vector layer has the capability to trigger a great fan of events.

The goal of this recipe is to show how easy it is to listen for events in a vector layer and know what is happening on it.

We are going to load a GML file with some cities around the world, and we will style its fill color depending on some feature attribute.

Listening for vector layer features' events

How to do it...

  1. Create an HTML file and add the ...

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