Editing vectorsΒΆ

Editing vectors in OpenLayers is usage of several controls, which are working with particular OpenLayers.Layer.Vector.

Usually, you want to have a panel with buttons in the map. OpenLayers.Control.Panel is a control too, see 04_editing.html.

1
2
            var panel = new OpenLayers.Control.Panel({displayClass:"olControlEditingToolbar"});
            map.addControl(panel);

Note

We have set special class name (attribute displayClass) to the control object. This is corresponding with class definition in CSS, so the control is displayed as button in the panel.

Editing controls must be bound with particular handlers.

1
2
3
4
            var path = new OpenLayers.Control.DrawFeature(vlayer, OpenLayers.Handler.Path, {'displayClass': 'olControlDrawFeaturePath'});
            var modify = new OpenLayers.Control.ModifyFeature(vlayer);

            panel.addControls([new OpenLayers.Control.Navigation(), path,modify]);

Note

OpenLayers.Control.Panel has only addControls([])() method, you always have to submit list of controls.

And add some other editing control to the map as well:

1
2
3
            var snapping = new OpenLayers.Control.Snapping({ layer:vlayer, targets: [vlayer]});
            map.addControl(snapping);
            snapping.activate();

Main Menu


Previous topic

Controls

Next topic

OpenLayers Event model

This Page