ठीक है, ModifyFeature
नियंत्रण को छोड़ दें और चयनित सुविधाओं का ट्रैक रखने के लिए बस SelectFeature
नियंत्रण में हुक करें और फिर चयनित बिंदुओं को एक ही समय में बदलने के लिए DragControl
का उपयोग करें। नियंत्रण इन्स्टेन्शियशन की
उदाहरण:
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
});
घटना का उदाहरण से निपटने कार्य:
/* Keep track of the selected features */
function addSelected(feature) {
selectedFeatures.push(feature);
}
/* Clear the list of selected features */
function clearSelected(feature) {
selectedFeatures = [];
}
/* Feature starting to move */
function startDrag(feature, pixel) {
lastPixel = pixel;
}
/* Feature moving */
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;
}
/* Featrue stopped moving */
function endDrag(feature, pixel) {
for (f in selectedFeatures) {
f.state = OpenLayers.State.UPDATE;
}
}
स्रोत
2010-12-09 20:57:56
इस के लिए धन्यवाद - यह मेरे लिए भी काम करता है, उम्मीद है कि एक बार सुविधाओं घसीटा गया है, वे अब चयन बॉक्स से" चयन "हैं, और फिर से स्थानांतरित नहीं किया जा सकता है। क्या आपको यह समस्या है? –
स्पष्ट उदाहरण के लिए धन्यवाद, ड्रैगिंग और घटनाओं पर एक साधारण उदाहरण खोजने के लिए मुझे लगभग एक दिन लग गया। यह बहुत अच्छा है! मैं इसे कई विशेषताओं के लिए उपयोग नहीं कर रहा हूं लेकिन 1. – Marco
के लिए इसे मिला, इसका इस्तेमाल किया और यह काम करता है :)। तो आप एक बड़ा धन्यवाद! – elrado