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

Time For Action – working with feature events

Let's take a quick look at a couple of the previous Vector class methods.

  1. Open up the first example from the chapter—we'll be using Firebug, and we'll just need a vector layer and EditingToolbar control. We won't be editing any code, so open up the first example and Firebug's JavaScript console.
  2. We're going to add a function using preFeatureInsert that will display an alert containing the feature's ID. This function will be triggered before the feature is inserted into the map. Type and run the following in Firebug to create the function as follows:
    map.layers[1].preFeatureInsert = function(feature){ 
      alert('preFeatureInsert – ID: ' + feature.id) 
    };
  3. Take a look at the map now and add a point using the EditingToolbar ...

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