Ok, skip the ModifyFeature control and just connect to the SelectFeature control to track the selected functions, and then use DragControl to control the selected points at the same time.
Example management instance:
var drag = new OpenLayers.Control.DragFeature(vectors, { onStart: startDrag, onDrag: doDrag, onComplete: endDrag }); var select = new OpenLayers.Control.SelectFeature(vectors, { box: true, multiple: true, onSelect: addSelected, onUnselect: clearSelected });
Example event handling functions:
function addSelected(feature) { selectedFeatures.push(feature); } function clearSelected(feature) { selectedFeatures = []; } function startDrag(feature, pixel) { lastPixel = pixel; } function doDrag(feature, pixel) { for (f in selectedFeatures) { if (feature != selectedFeatures[f]) { var res = map.getResolution(); selectedFeatures[f].geometry.move(res * (pixel.x - lastPixel.x), res * (lastPixel.y - pixel.y)); vectors.drawFeature(selectedFeatures[f]); } } lastPixel = pixel; } function endDrag(feature, pixel) { for (f in selectedFeatures) { f.state = OpenLayers.State.UPDATE; } }
Wally atkins
source share