[OpenLayers-Users] Drag cancellation ?
Attila Csipa
plists at prometheus.org.yu
Mon Jan 7 07:56:30 EST 2008
On Monday 07 January 2008 12:39:30 Eric Lemoine wrote:
> > > Off the top of my head: you could try to erase the feature before
> > > calling layer.redraw() in the onComplete() callback. To erase the
> > > feature use feature.layer.eraseFeatures([feature]).
> >
> > one feature with one geometry. The magic line in onComplete (before
> > restoring the original geometry) thus is:
> >
> > feature.layer.renderer.eraseGeometry(feature.geometry);
>
> The line I gave you does just the same in this case I guess.
Almost - the dragged feature is not a copy, so if you do removeFeatures() it's
gone for good (sort of blackholed instead of reverting to a previous state so
the user can try dragging again). You could, of course, clone the whole
feature in which case you CAN erase and replace it, but it seemed an overkill
as the feature had a hefty attribute array and the only thing that needed
reverting was the geometry (feature cloning has other possible drawbacks if
one is not careful as they are sometimes expected to be sort-of persistent -
IDs, order, etc).
More information about the Users
mailing list