Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • OpenLayers 2.10 Beginner's Guide
  • Toc
  • feedback
OpenLayers 2.10 Beginner's Guide

OpenLayers 2.10 Beginner's Guide

4.2 (9)
close
OpenLayers 2.10 Beginner's Guide

OpenLayers 2.10 Beginner's Guide

4.2 (9)

Overview of this book

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

Time For Action – using Vector Layer events


Now that you know the possible event types, let's play around with some.

  1. Open up the first example from this chapter. We won't be editing the code, but instead we'll use Firebug again. We just need a vector layer and EditingToolbar control. As in the previous chapters, map.layers[1] is assumed to be the vector layer.

  2. Open up Firebug. We'll start off by registering a beforefeatureadded event to the map. First, like in Chapter 8, we need to create a listener function that will get called when the event fires. We know from the previous list of event types that the listener function will receive an object containing the feature, so let's create our function with a feature parameter that will reference the feature. In Firebug, create a function:

    function before_feature_added(feature){ console.log('before adding a feature!', feature); };
  3. All we have to do now is register the beforefeatureadded event on our vector layer:

    map.layers[1].events.register('beforefeatureadded...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete