I am new to OpenLayers and I'm trying to drag markers and skip some markers from being dragged, I've tried dragFeature.deactivate();
it will deactivate entire features.
Please check this code :
dragFeature = new OpenLayers.Control.DragFeature(vectorLayer, {
autoActivate: true,
onEnter: function (feature) {
// example assign : x=1;
// if(x==0){ continue draging of a feature }
// else{ stop a feature from being dragged }
},
onLeave: function (feature) {
},
onStart: function (feature, pixel) {
},
onComplete: function (feature, pixel) {
}
});
map.addControl(dragFeature);
dragFeature.activate();
Please help me.
Answer
You can check feature attributes and deactivate drag handler for some values:
drag.onStart = function(f,p) {
if (f.attributes.draggable === false) {
drag.handlers.drag.deactivate();
}
}
No comments:
Post a Comment