Editing features on multiple vector layers
When working with vector information, most probably, one of the most common things we can do in a GIS application is: add new features.
OpenLayers has plenty of controls, so there is no need to reinvent the wheel. We have a set of tools and the only thing we need to do is learn how to use each one.
For this concrete purpose, add new features. OpenLayers has the OpenLayers.Control.EditingToolbar
control that shows a toolbar with some buttons to add polygons, polylines, and points:
Because we can have many vector layers in the map, the control needs us to specify the layer it must work on.
In addition to showing how easy is to use the control, the goal of this recipe is to show how we can use the same control to add features to more than one layer.
This way, this little application will consist of a map with two vector layers. Thanks to the radio buttons, we will be able to chose the layer on which we want to create the new features.
How to do it...
First...