[OpenLayers-Users] Drag cancellation ?
Attila Csipa
plists at prometheus.org.yu
Sat Jan 5 13:13:25 EST 2008
I was writing functions for a DragFreature control and wanted to implement an
undo/invalid choice type of feature, but I can't seem to find how to cancel a
drag (if f.e. the drop location is found to be invalid in the onComplete
function). I tried restoring geometry (which I saved in onStart) but that
didn't quite work as expected (leaves me with 2 drawn features, on both new
AND old locations, although the number of features in the layer has not
changed) so I'm under the impression there is a simpler way of doing this or
it's just that I can't see the forest from the tree...
var undogeometry = null;
var drag = new OpenLayers.Control.DragFeature(pointlayer,{
onStart: function(feature, pixel)
{
undogeometry = feature.geometry.clone();
},
onComplete: function(feature, pixel)
{
if (invalid_loc(feature.geometry))
{
feature.geometry.destroy();
feature.geometry = undogeometry.clone();
undogeometry.destroy();
feature.layer.redraw();
alert('Invalid location !');
}
}
});
More information about the Users
mailing list